OpenSearch: Local running instance with Docker with M1

waytohksharma
3 min readJun 28, 2023

--

Docker made a life easy to bring any of the local instance is simple steps.

Today let’s try to the OpenSearch Instance with OpenSearch Service and DashBoard UI

What is OpenSearch and what is use of OpenSeacrh

OpenSearch is a scalable, flexible, and extensible open-source software suite for search, analytics, and observability applications licensed under Apache 2.0. Powered by Apache Lucene and driven by the OpenSearch Project community, OpenSearch offers a vendor-agnostic toolset you can use to build secure, high-performance, cost-efficient applications. Use OpenSearch as an end-to-end solution or connect it with your preferred open-source tools or partner projects.

https://opensearch.org/

Lets get set up OpenSearch on your local machine with M1

OpenSearch images are available for docker containers on docker hub, that makes it super simple to run it anywhere.

What you need to have your machine is the docker up and running.

If you don’t have docker installed on your machine you can follow the instruction provided from“here” and Verify the installation using.

I am using the following version of docker-

docker — version
Docker version 20.10.21

OpenSearch has two main components. First opensearch itself the engine and second open search dashboards UI.

Just like Elasticsearch and Kibana. To run both together and have them talk to each other we will use docker compose.

Create docker compose file with the name of

docker-compose.yaml with following content in any of the specified folder

version: '3'
services:
opensearch-node1:
image: opensearchproject/opensearch:latest
container_name: opensearch-node1
environment:
- cluster.name=opensearch-cluster
- node.name=opensearch-node1
- discovery.seed_hosts=opensearch-node1,opensearch-node2
- cluster.initial_cluster_manager_nodes=opensearch-node1,opensearch-node2
- bootstrap.memory_lock=true # along with the memlock settings below, disables swapping
- "OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m" # minimum and maximum Java heap size, recommend setting both to 50% of system RAM
ulimits:
memlock:
soft: -1
hard: -1
nofile:
soft: 65536 # maximum number of open files for the OpenSearch user, set to at least 65536 on modern systems
hard: 65536
volumes:
- opensearch-data1:/usr/share/opensearch/data
ports:
- 9200:9200
- 9600:9600 # required for Performance Analyzer
networks:
- opensearch-net
opensearch-node2:
image: opensearchproject/opensearch:latest
container_name: opensearch-node2
environment:
- cluster.name=opensearch-cluster
- node.name=opensearch-node2
- discovery.seed_hosts=opensearch-node1,opensearch-node2
- cluster.initial_cluster_manager_nodes=opensearch-node1,opensearch-node2
- bootstrap.memory_lock=true
- "OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m"
ulimits:
memlock:
soft: -1
hard: -1
nofile:
soft: 65536
hard: 65536
volumes:
- opensearch-data2:/usr/share/opensearch/data
networks:
- opensearch-net
opensearch-dashboards:
image: opensearchproject/opensearch-dashboards:latest
container_name: opensearch-dashboards
ports:
- 5601:5601
expose:
- "5601"
environment:
OPENSEARCH_HOSTS: '["https://opensearch-node1:9200","https://opensearch-node2:9200"]'
networks:
- opensearch-net

volumes:
opensearch-data1:
opensearch-data2:

networks:
opensearch-net:

Lets run the

docker-compose up -d

To verify if Open Search instance is up and running just type-

docker ps


CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
e68c98784866 opensearchproject/opensearch-dashboards:latest "./opensearch-dashbo…" 21 hours ago Up 21 hours 0.0.0.0:5601->5601/tcp opensearch-dashboards
7be9e7d61d83 opensearchproject/opensearch:latest "./opensearch-docker…" 21 hours ago Up 21 hours 0.0.0.0:9200->9200/tcp, 9300/tcp, 0.0.0.0:9600->9600/tcp, 9650/tcp opensearch-node1

Lets look at the Dashboards

On your browser open

http://localhost:5601/

Username: admin
Password: admin

You will se window like-

To run the single node instance you can try

docker run -p 9200:9200 -e "discovery.type=single-node" opensearchproject/opensearch

--

--

waytohksharma

Cloud Architect with 16+ years of experience. I enjoy doing PoC about emerging technologies, staying up-to-date on tech. Play with AWS, Java, API, Microservice.