How to Install OpenSearch with Docker
Introduction
OpenSearch is an open-source search and analytics solution. In this guide, you’ll learn how to install OpenSearch using Docker to simplify its deployment and management.
Step 1: Verify Prerequisites
Before starting, make sure you have:
- Docker Engine: Official guide to install Docker.
- Docker Compose: Official guide to install Docker Compose.
Step 2: Create a Docker Network
Create a network that allows communication between OpenSearch services:
docker network create opensearch-net
Step 3: Create a docker-compose.yml File
In your working directory, create a file called docker-compose.yml
and copy the following content:
version: '3'
services:
opensearch-node1:
image: opensearchproject/opensearch:latest
container_name: opensearch-node1
environment:
- discovery.type=single-node
- bootstrap.memory_lock=true
- OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m
ulimits:
memlock:
soft: -1
hard: -1
volumes:
- opensearch-data1:/usr/share/opensearch/data
ports:
- 9200:9200
networks:
- opensearch-net
opensearch-dashboards:
image: opensearchproject/opensearch-dashboards:latest
container_name: opensearch-dashboards
ports:
- 5601:5601
environment:
OPENSEARCH_HOSTS: '["http://opensearch-node1:9200"]'
networks:
- opensearch-net
volumes:
opensearch-data1:
Important Details:
discovery.type=single-node
: Configures a single node (ideal for testing).OPENSEARCH_JAVA_OPTS
: Limits container memory usage to 512 MB.- Volumes (
opensearch-data1
) ensure data persistence after container restarts.
Step 4: Start the Services
Run the following command in the directory where your docker-compose.yml
file is located:
docker-compose up -d
This will download the necessary images and launch the containers in the background.
Step 5: Verify Container Status
To confirm that the services are running, execute:
docker-compose ps
You should see the opensearch-node1
and opensearch-dashboards
containers in Up state.
Step 6: Access OpenSearch
-
API Interface: Verify that OpenSearch is active with this command:
curl -X GET "http://localhost:9200/"
This will return information about your node.
-
OpenSearch Dashboards: Open your browser and go to
http://localhost:5601
to access the graphical interface.
Step 7: Additional Considerations
- Security: Configure authentication and TLS for production environments. Consult the official documentation.
- Data persistence: Use volumes to prevent data loss.
- Backups and monitoring: Implement backup and monitoring strategies.