docker.recipes

OpenSearch + Dashboards

intermediate

Open source search and analytics suite.

Overview

OpenSearch is a community-driven, open source search and analytics suite derived from Elasticsearch 7.10.2 and Kibana 7.10.2. Created by Amazon as a response to Elastic's license change, OpenSearch maintains full compatibility with the Elasticsearch REST APIs while remaining under the Apache 2.0 license. It provides distributed search capabilities, real-time analytics, and machine learning features for handling large-scale data workloads across various use cases from log analytics to application search. This deployment consists of two services: a single-node OpenSearch cluster configured for standalone operation, and OpenSearch Dashboards for data visualization and cluster management. The OpenSearch service runs with 512MB heap memory allocation and operates in single-node discovery mode, making it suitable for development, testing, or small production workloads. The dashboards service connects directly to the OpenSearch instance over HTTPS, providing a web-based interface for data exploration, visualization creation, and cluster administration. This configuration is ideal for teams migrating from Elasticsearch who want to maintain API compatibility, organizations requiring open source search solutions without licensing restrictions, and developers building search-driven applications. The combination provides both the search engine capabilities and the visualization tools needed for comprehensive data analysis workflows, from ingesting documents to creating interactive dashboards and monitoring search performance.

Key Features

  • Full Elasticsearch REST API compatibility for seamless migration from existing applications
  • Built-in security with TLS encryption and authentication enabled by default
  • Real-time search and analytics with support for complex queries and aggregations
  • Machine learning capabilities including anomaly detection and k-NN search
  • Index State Management (ISM) for automated lifecycle policies and data retention
  • Performance analyzer for monitoring cluster health and query performance
  • Cross-cluster replication support for disaster recovery and data distribution
  • Plugin architecture with support for custom analyzers, processors, and extensions

Common Use Cases

  • 1Application search functionality for e-commerce, content management, or documentation platforms
  • 2Log analytics and monitoring for DevOps teams collecting application and infrastructure logs
  • 3Business intelligence dashboards combining search results with data visualizations
  • 4Security information and event management (SIEM) for analyzing security logs and alerts
  • 5Real-time analytics for user behavior tracking and product recommendation engines
  • 6Migration testing environment for teams moving away from Elastic Stack
  • 7Development and staging environments requiring lightweight search infrastructure

Prerequisites

  • Minimum 2GB RAM available for containers (512MB each for OpenSearch JVM plus overhead)
  • Docker host with vm.max_map_count set to at least 262144 for OpenSearch memory mapping
  • Ports 9200, 9600, and 5601 available on the host system
  • ADMIN_PASSWORD environment variable set with at least 8 characters including uppercase, lowercase, and numbers
  • Understanding of Elasticsearch query DSL and index management concepts
  • Basic knowledge of Lucene query syntax for search operations

For development & testing. Review security settings, change default credentials, and test thoroughly before production use. See Terms

docker-compose.yml

docker-compose.yml
1services:
2 opensearch:
3 image: opensearchproject/opensearch:latest
4 environment:
5 - cluster.name=opensearch-cluster
6 - node.name=opensearch-node
7 - discovery.type=single-node
8 - bootstrap.memory_lock=true
9 - OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m
10 - OPENSEARCH_INITIAL_ADMIN_PASSWORD=${ADMIN_PASSWORD}
11 ulimits:
12 memlock:
13 soft: -1
14 hard: -1
15 nofile:
16 soft: 65536
17 hard: 65536
18 volumes:
19 - opensearch-data:/usr/share/opensearch/data
20 ports:
21 - "9200:9200"
22 - "9600:9600"
23 networks:
24 - opensearch-network
25 restart: unless-stopped
26
27 dashboards:
28 image: opensearchproject/opensearch-dashboards:latest
29 environment:
30 - OPENSEARCH_HOSTS=["https://opensearch:9200"]
31 ports:
32 - "5601:5601"
33 depends_on:
34 - opensearch
35 networks:
36 - opensearch-network
37 restart: unless-stopped
38
39volumes:
40 opensearch-data:
41
42networks:
43 opensearch-network:
44 driver: bridge

.env Template

.env
1# OpenSearch
2ADMIN_PASSWORD=SecurePassword123!
3
4# Password requirements:
5# Min 8 chars, uppercase, lowercase, number, special char

Usage Notes

  1. 1OpenSearch at https://localhost:9200
  2. 2Dashboards at http://localhost:5601
  3. 3Default user: admin
  4. 4REST API compatible
  5. 5Kibana alternative

Individual Services(2 services)

Copy individual services to mix and match with your existing compose files.

opensearch
opensearch:
  image: opensearchproject/opensearch:latest
  environment:
    - cluster.name=opensearch-cluster
    - node.name=opensearch-node
    - discovery.type=single-node
    - bootstrap.memory_lock=true
    - OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m
    - OPENSEARCH_INITIAL_ADMIN_PASSWORD=${ADMIN_PASSWORD}
  ulimits:
    memlock:
      soft: -1
      hard: -1
    nofile:
      soft: 65536
      hard: 65536
  volumes:
    - opensearch-data:/usr/share/opensearch/data
  ports:
    - "9200:9200"
    - "9600:9600"
  networks:
    - opensearch-network
  restart: unless-stopped
dashboards
dashboards:
  image: opensearchproject/opensearch-dashboards:latest
  environment:
    - OPENSEARCH_HOSTS=["https://opensearch:9200"]
  ports:
    - "5601:5601"
  depends_on:
    - opensearch
  networks:
    - opensearch-network
  restart: unless-stopped

Quick Start

terminal
1# 1. Create the compose file
2cat > docker-compose.yml << 'EOF'
3services:
4 opensearch:
5 image: opensearchproject/opensearch:latest
6 environment:
7 - cluster.name=opensearch-cluster
8 - node.name=opensearch-node
9 - discovery.type=single-node
10 - bootstrap.memory_lock=true
11 - OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m
12 - OPENSEARCH_INITIAL_ADMIN_PASSWORD=${ADMIN_PASSWORD}
13 ulimits:
14 memlock:
15 soft: -1
16 hard: -1
17 nofile:
18 soft: 65536
19 hard: 65536
20 volumes:
21 - opensearch-data:/usr/share/opensearch/data
22 ports:
23 - "9200:9200"
24 - "9600:9600"
25 networks:
26 - opensearch-network
27 restart: unless-stopped
28
29 dashboards:
30 image: opensearchproject/opensearch-dashboards:latest
31 environment:
32 - OPENSEARCH_HOSTS=["https://opensearch:9200"]
33 ports:
34 - "5601:5601"
35 depends_on:
36 - opensearch
37 networks:
38 - opensearch-network
39 restart: unless-stopped
40
41volumes:
42 opensearch-data:
43
44networks:
45 opensearch-network:
46 driver: bridge
47EOF
48
49# 2. Create the .env file
50cat > .env << 'EOF'
51# OpenSearch
52ADMIN_PASSWORD=SecurePassword123!
53
54# Password requirements:
55# Min 8 chars, uppercase, lowercase, number, special char
56EOF
57
58# 3. Start the services
59docker compose up -d
60
61# 4. View logs
62docker compose logs -f

One-Liner

Run this command to download and set up the recipe in one step:

terminal
1curl -fsSL https://docker.recipes/api/recipes/opensearch-complete/run | bash

Troubleshooting

  • OpenSearch fails to start with memory errors: Increase Docker memory limits or adjust OPENSEARCH_JAVA_OPTS heap size
  • Dashboards shows 'Unable to connect to OpenSearch' error: Verify opensearch service is healthy and check network connectivity between containers
  • Authentication failed with admin user: Ensure ADMIN_PASSWORD environment variable is set and meets complexity requirements
  • Bootstrap check failures on startup: Set vm.max_map_count=262144 on Docker host system using sysctl
  • Port binding errors on 9200 or 5601: Check for conflicting services and ensure ports are not already in use
  • Low disk watermark exceeded warnings: Monitor opensearch-data volume usage and configure appropriate disk space

Community Notes

Loading...
Loading notes...

Download Recipe Kit

Get all files in a ready-to-deploy package

Includes docker-compose.yml, .env template, README, and license

Ad Space