---
title: "OpenSearch Docker Compose and one-click hosting"
description: "OpenSearch is an open-source search and analytics engine, forked from Elasticsearch. Self-host it with OpenSearch Dashboards in one click."
---

[← All templates](https://pethost.dev/templates/) · [Developer tools](https://pethost.dev/templates/developer-tools/)

# Deploy OpenSearch in one click

Open-source search and analytics engine, with OpenSearch Dashboards: full-text and vector search, logs and dashboards

A self-hosted alternative to Elasticsearch and Algolia.

[Deploy on Pethost](https://console.pethost.dev/?template=opensearch)

## What is OpenSearch?

OpenSearch is a search and analytics engine: you send it JSON documents over a REST API, and it finds them by full text, filters and aggregates them, and searches them by vector for AI apps with its k-NN plugin. OpenSearch Dashboards is its web interface: dashboards and charts, Discover for exploring logs and events, Dev Tools for sending queries, and pages for its plugins, such as security, alerting and anomaly detection.

OpenSearch began in 2021 as a fork of Elasticsearch 7.10.2 and Kibana, when Elastic changed their license, and is open source under Apache 2.0. Since 2024 it is run by the OpenSearch Software Foundation, part of the Linux Foundation. This template runs one node with OpenSearch Dashboards at the project's address, with the security plugin on: its only users are the administrator, made from the fields before OpenSearch answers anyone, and Dashboards' own, so none of the image's demo users with published passwords. The catch: it runs on Java and takes more memory than lighter search engines, and one node keeps no replica of its indexes.

## Hosting OpenSearch on Pethost

1. You sign in to Pethost with a passkey, GitHub or Google. No machine yet? You pick a plan, and the link waits until it is ready.
2. New project opens at OpenSearch. You fill in what it asks for and click Create project: **Admin password**.
3. In a minute or two OpenSearch is live at its own address with HTTPS. Its secrets are made at random, and its data is in the nightly backup.
4. It is a project like any other: you or your agent can change it, roll it back or restore it.

## Questions about OpenSearch

**Is OpenSearch free?**

Yes. OpenSearch and OpenSearch Dashboards are open source under the Apache 2.0 license, with every plugin included and no paid edition. Amazon sells a managed version, Amazon OpenSearch Service.

**OpenSearch vs Elasticsearch: what is the difference?**

OpenSearch started as a fork of Elasticsearch 7.10.2 in 2021, so its query language and REST API look familiar, but the two have moved apart since. OpenSearch is Apache 2.0 with security, alerting and vector search built in, while Elasticsearch is sold by Elastic under its own licenses and the AGPL.

**Can I use OpenSearch for vector search?**

Yes. Its k-NN plugin stores vectors beside your documents and finds the nearest ones, with the Lucene and Faiss engines, and its neural search plugin combines that with text search, for semantic search and retrieval for AI apps.

**How do my apps connect to OpenSearch?**

Over its REST API on port 9200. Add a host on the project's Domains tab with a route to the opensearch service on that port, and connect with an official client (Python, JavaScript, Java, Go, Ruby, PHP, .NET or Rust) or plain HTTPS, signed in as admin or as a user you make for the app.

**How much memory and disk does OpenSearch need?**

OpenSearch runs on Java with a 512 MB heap: about 1.3 GB of memory with OpenSearch Dashboards at rest, more as indexes grow; for large indexes, raise the heap in OPENSEARCH_JAVA_OPTS. On Pethost the Starter plan is enough for it, with room for other apps beside it.

## OpenSearch Docker Compose file

The template is this compose.yaml and the variables written into the project’s .env as it is created. Pethost runs the file as it is written.

**Containers:** opensearch (opensearchproject/opensearch:3), dashboards (opensearchproject/opensearch-dashboards:3).

**Volumes, in the nightly backup:** data.

```
services:
  opensearch:
    image: opensearchproject/opensearch:3
    restart: unless-stopped
    environment:
      OPENSEARCH_JAVA_OPTS: -Xms512m -Xmx512m
      ADMIN_PASSWORD: ${ADMIN_PASSWORD}
      DASHBOARDS_PASSWORD: ${DASHBOARDS_PASSWORD}
      # The image's demo configuration would add its demo users, whose passwords are published,
      # and certificates whose keys are too: this start writes its own instead.
      DISABLE_INSTALL_DEMO_CONFIG: "true"
    # At each start: a certificate authority and a node certificate of this container's own for
    # the security plugin's transport layer, made with the JDK's keytool, as the image has no
    # openssl; opensearch.yml with them; and the users the security index is made from at the
    # first start: the administrator with the password given, not reserved, so that it can change
    # its password with no admin certificate, and OpenSearch Dashboards' server user. Once the index exists, OpenSearch reads its users from it, and a password changed in
    # OpenSearch Dashboards stays. A single node holds no replica, so an index asks for none. The
    # REST API answers over HTTP inside the project, where the proxy brings HTTPS requests.
    command:
      - bash
      - -c
      - |
        set -e
        cd /usr/share/opensearch
        if [ "$${#ADMIN_PASSWORD}" -lt 8 ]; then
          echo "The admin password must have 8 characters at least, as OpenSearch asks." >&2
          exit 1
        fi
        keytool=jdk/bin/keytool
        certs=config/certs
        store=$$(head -c 16 /dev/urandom | od -An -tx1 | tr -d ' \n')
        rm -rf "$$certs"
        mkdir -p "$$certs"
        $$keytool -genkeypair -alias ca -keyalg RSA -keysize 2048 -validity 3650 -dname CN=opensearch-ca -ext bc:c \
          -keystore "$$certs/ca.p12" -storetype PKCS12 -storepass "$$store" 2> /dev/null
        $$keytool -exportcert -rfc -alias ca -keystore "$$certs/ca.p12" -storepass "$$store" -file "$$certs/ca.pem" 2> /dev/null
        $$keytool -genkeypair -alias node -keyalg RSA -keysize 2048 -validity 3650 -dname CN=opensearch \
          -keystore "$$certs/node.p12" -storetype PKCS12 -storepass "$$store" 2> /dev/null
        $$keytool -certreq -alias node -keystore "$$certs/node.p12" -storepass "$$store" -file "$$certs/node.csr" 2> /dev/null
        $$keytool -gencert -rfc -alias ca -keystore "$$certs/ca.p12" -storepass "$$store" -validity 3650 \
          -ext SAN=dns:opensearch,dns:localhost -ext KU=digitalSignature,keyEncipherment -ext EKU=serverAuth,clientAuth \
          -infile "$$certs/node.csr" -outfile "$$certs/node.pem" 2> /dev/null
        $$keytool -importcert -noprompt -alias ca -file "$$certs/ca.pem" -keystore "$$certs/node.p12" -storepass "$$store" 2> /dev/null
        $$keytool -importcert -noprompt -alias node -file "$$certs/node.pem" -keystore "$$certs/node.p12" -storepass "$$store" 2> /dev/null
        $$keytool -importcert -noprompt -alias ca -file "$$certs/ca.pem" -keystore "$$certs/trust.p12" -storetype PKCS12 -storepass "$$store" 2> /dev/null
        rm "$$certs/ca.p12" "$$certs/node.csr"
        cat > config/opensearch.yml <<YAML
        cluster.name: opensearch
        network.host: 0.0.0.0
        discovery.type: single-node
        cluster.default_number_of_replicas: 0
        plugins.security.ssl.transport.keystore_type: PKCS12
        plugins.security.ssl.transport.keystore_filepath: certs/node.p12
        plugins.security.ssl.transport.keystore_password: $$store
        plugins.security.ssl.transport.truststore_type: PKCS12
        plugins.security.ssl.transport.truststore_filepath: certs/trust.p12
        plugins.security.ssl.transport.truststore_password: $$store
        plugins.security.ssl.transport.enforce_hostname_verification: false
        plugins.security.ssl.http.enabled: false
        plugins.security.nodes_dn: ["CN=opensearch"]
        plugins.security.allow_default_init_securityindex: true
        plugins.security.restapi.roles_enabled: ["all_access", "security_rest_api_access"]
        YAML
        hash() { plugins/opensearch-security/tools/hash.sh -env "$$1" 2> /dev/null | tail -n 1; }
        cat > config/opensearch-security/internal_users.yml <<YAML
        _meta:
          type: internalusers
          config_version: 2
        admin:
          hash: "$$(hash ADMIN_PASSWORD)"
          reserved: false
          backend_roles: [admin]
          description: The administrator
        kibanaserver:
          hash: "$$(hash DASHBOARDS_PASSWORD)"
          reserved: true
          description: OpenSearch Dashboards' server
        YAML
        exec ./opensearch-docker-entrypoint.sh opensearch
    volumes:
      - data:/usr/share/opensearch/data
    # Up means answering, which asks for a password: 401 to a request with none.
    healthcheck:
      test: ["CMD-SHELL", "code=$$(curl -s -o /dev/null -w '%{http_code}' http://127.0.0.1:9200/); [ \"$$code\" = 401 ]"]
      interval: 5s
      timeout: 5s
      retries: 10
      start_period: 120s

  dashboards:
    image: opensearchproject/opensearch-dashboards:3
    restart: unless-stopped
    environment:
      OPENSEARCH_HOSTS: '["http://opensearch:9200"]'
      OPENSEARCH_USERNAME: kibanaserver
      OPENSEARCH_PASSWORD: ${DASHBOARDS_PASSWORD}
    depends_on:
      opensearch:
        condition: service_healthy

volumes:
  data:
```

[compose.yaml](https://pethost.dev/templates/opensearch/compose.yaml)[See it on GitHub](https://github.com/pethost-dev/templates/tree/main/opensearch)

## [More in Developer tools](https://pethost.dev/templates/developer-tools/)

- [**Gitea**Git hosting with pull requests and issues](https://pethost.dev/templates/gitea/)
- [**code-server**VS Code in the browser](https://pethost.dev/templates/code-server/)
- [**Kroki**Diagrams from text: PlantUML, Mermaid, Graphviz and more](https://pethost.dev/templates/kroki/)
- [**Coder**Remote development environments from Terraform templates, opened in VS Code, JetBrains, a browser or over SSH](https://pethost.dev/templates/coder/)
- [**Hasura**Instant GraphQL and REST APIs over a Postgres database, with permissions, events and a web console](https://pethost.dev/templates/hasura/)
- [**InsForge**A backend for apps that coding agents build: Postgres, auth, storage and edge functions](https://pethost.dev/templates/insforge/)

Pethost · Stephan Gomer · NIP 1133096755

Pethost

- [Templates](https://pethost.dev/templates/)
- [About](https://pethost.dev/about/)
- [Docs](https://pethost.dev/docs/)
- [Blog](https://pethost.dev/blog/)
- [API](https://pethost.dev/docs/api/)
- [CLI](https://pethost.dev/docs/cli/)
- [Plugin](https://github.com/pethost-dev/plugin)
- [Terms](https://pethost.dev/terms/)
- [Privacy](https://pethost.dev/privacy/)
- [Refunds](https://pethost.dev/refunds/)
- [support@pethost.dev](mailto:support@pethost.dev)

Databases

- [Postgres](https://pethost.dev/postgres/)

Comparisons

- [Coolify vs Dokploy vs CapRover vs Dokku](https://pethost.dev/blog/coolify-vs-dokploy-vs-caprover-vs-dokku/)
- [Coolify Cloud vs Dokploy Cloud](https://pethost.dev/blog/coolify-cloud-vs-dokploy-cloud/)
- [Railway vs Render vs Fly.io pricing](https://pethost.dev/blog/railway-vs-render-vs-fly-io-pricing/)
- [Managed Docker Compose hosting](https://pethost.dev/blog/managed-docker-compose-hosting/)

Alternatives

- [Railway alternatives](https://pethost.dev/blog/railway-alternatives/)
- [Heroku alternatives](https://pethost.dev/blog/heroku-alternatives/)
- [Dokploy alternatives](https://pethost.dev/blog/dokploy-alternatives/)
- [Coolify alternatives](https://pethost.dev/blog/coolify-alternatives/)
- [Render alternatives](https://pethost.dev/blog/render-alternatives/)
- [Sliplane alternatives](https://pethost.dev/blog/sliplane-alternatives/)
