Docker image
To check available versions, see .
OpenSearch images use as the base image. If you run Docker locally, set Docker to use at least 4 GB of RAM in Preferences > Resources.
To run the image for local development:
docker run -p 9200:9200 -p 9600:9600 -e "discovery.type=single-node" opensearchproject/opensearch:2.0.0
Then send requests to the server to verify that OpenSearch is up and running:
curl -XGET https://localhost:9200 -u 'admin:admin' --insecure
curl -XGET https://localhost:9200/_cat/nodes?v -u 'admin:admin' --insecure
curl -XGET https://localhost:9200/_cat/plugins?v -u 'admin:admin' --insecure
To find the container ID:
docker ps
Then you can stop the container using:
docker stop <container-id>
Start a cluster
To deploy multiple nodes and simulate a more realistic deployment, create a file appropriate for your environment and run:
docker-compose up
To stop the cluster, run:
docker-compose down
To stop the cluster and delete all data volumes, run:
docker-compose down -v
If you’re running your cluster in a production environment, be sure to refer to Important settings when configuring your machine and cluster.
Sample Docker Compose file
If you override opensearch_dashboards.yml
settings using environment variables, as seen above, use all uppercase letters and underscores in place of periods (e.g. for opensearch.hosts
, use OPENSEARCH_HOSTS
).
You can pass a custom opensearch.yml
file to the Docker container using the -v flag for docker run
:
docker run \
-p 9200:9200 -p 9600:9600 \
-e "discovery.type=single-node" \
opensearchproject/opensearch:2.0.0
You can perform the same operation in docker-compose.yml
using a relative path:
services:
opensearch-node1:
volumes:
- ./custom-opensearch.yml:/usr/share/opensearch/config/opensearch.yml
opensearch-node2:
volumes:
- opensearch-data2:/usr/share/opensearch/data
- ./custom-opensearch.yml:/usr/share/opensearch/config/opensearch.yml
opensearch-dashboards:
volumes:
- ./custom-opensearch_dashboards.yml:/usr/share/opensearch-dashboards/config/opensearch_dashboards.yml
You can also configure docker-compose.yml
and opensearch.yml
for use with the Security plugin.
Enable the Performance Analyzer plugin:
curl -XPOST localhost:9200/_plugins/_performanceanalyzer/cluster/config -H 'Content-Type: application/json' -d '{"enabled": true}'
If you receive the
curl: (52) Empty reply from server
error, you are likely protecting your cluster with the security plugin and you need to provide credentials. Modify the following command to use your username and password:curl -XPOST https://localhost:9200/_plugins/_performanceanalyzer/cluster/config -H 'Content-Type: application/json' -d '{"enabled": true}' -u 'admin:admin' -k
Enable the Root Cause Analyzer (RCA) framework
curl -XPOST localhost:9200/_plugins/_performanceanalyzer/rca/cluster/config -H 'Content-Type: application/json' -d '{"enabled": true}'
Similar to step 1, if you run into
curl: (52) Empty reply from server
, run the command below to enable RCAcurl -XPOST https://localhost:9200/_plugins/_performanceanalyzer/rca/cluster/config -H 'Content-Type: application/json' -d '{"enabled": true}' -u 'admin:admin' -k
By default, Performance Analyzer’s endpoints are not accessible from outside the Docker container.
To edit this behavior, open a shell session in the container and modify the configuration:
docker exec -it <container-id> /bin/bash
# Inside container
cd config/opensearch-performance-analyzer/
vi performance-analyzer.properties
Then restart the Performance Analyzer agent:
Bash access to containers
To create an interactive Bash session in a container, run docker ps
to find the container ID. Then run:
docker exec -it <container-id> /bin/bash
To run the image with a custom plugin, first create a Dockerfile:
FROM opensearchproject/opensearch:2.0.0
RUN /usr/share/opensearch/bin/opensearch-plugin install --batch <plugin-name-or-url>
Then run the following commands:
docker build --tag=opensearch-custom-plugin .
docker run -p 9200:9200 -p 9600:9600 -v /usr/share/opensearch/data opensearch-custom-plugin
You can also use a Dockerfile
to pass your own certificates for use with the plugin, similar to the -v
argument in Configure OpenSearch:
FROM opensearchproject/opensearch:2.0.0
COPY --chown=opensearch:opensearch opensearch.yml /usr/share/opensearch/config/
COPY --chown=opensearch:opensearch my-key-file.pem /usr/share/opensearch/config/
COPY --chown=opensearch:opensearch my-certificate-chain.pem /usr/share/opensearch/config/
COPY --chown=opensearch:opensearch my-root-cas.pem /usr/share/opensearch/config/
Alternately, you might want to remove a plugin. This Dockerfile
removes the security plugin:
FROM opensearchproject/opensearch:2.0.0
RUN /usr/share/opensearch/bin/opensearch-plugin remove opensearch-security
COPY --chown=opensearch:opensearch opensearch.yml /usr/share/opensearch/config/
In this case, opensearch.yml
is a “vanilla” version of the file with no plugin entries. It might look like this:
cluster.name: "docker-cluster"
Sample Docker Compose file for development
You can use this sample file as a development environment.
This sample file starts one OpenSearch node and a container for OpenSearch Dashboards with the security plugin disabled.
The environment variable "DISABLE_SECURITY_DASHBOARDS_PLUGIN=true"
disables the security dashboards plugin in OpenSearch Dashboards by removing the security dashboards plugin folder, removing all related settings in the opensearch_dashboards.yml
file, and setting the opensearch.hosts
entry protocol from HTTPS to HTTP. You can’t reverse this step as the security dashboards plugin is removed in the process. To re-enable security for OpenSearch Dashboards, start a new container and set to false or leave it unset.