Run multiple Elasticsearch instances on one server using Docker

John Doe ·

1476 Views

<Without docker-compose.yml>

1. Install Docker

2. Elasticsearch 7.16.2

2-1. Install Elasticsearch

# docker pull docker.elastic.co/elasticsearch/elasticsearch:7.16.2

2-2. Execute Elasticsearch

# docker run -d -p 9200:9200 -p 9300:9300 --name es_x -e "discovery.type=single-node" -e "xpack.security.enabled=false" -e ES_JAVA_OPTS="-Xms200m -Xmx200m" docker.elastic.co/elasticsearch/elasticsearch:7.16.2
8fd1161fed14b8e048e0f929a37cfacbab56371dc4c2b134602469c321cc0421

2-3. Check Execution

# docker ps
CONTAINER ID   IMAGE                                                  COMMAND                  CREATED          STATUS          PORTS                                            NAMES
8fd1161fed14   docker.elastic.co/elasticsearch/elasticsearch:7.16.2   "/bin/tini -- /usr/l…"   45 seconds ago   Up 43 seconds   0.0.0.0:9200->9200/tcp, 0.0.0.0:9300->9300/tcp   es_x

2-4. Check your Elasticsearch settings

# docker exec -i -t es_x cat /usr/share/elasticsearch/config/elasticsearch.yml
cluster.name: "docker-cluster"
network.host: 0.0.0.0

2-5. Stop

# docker stop es_x
es_x

 

<With docker-compose.yml>

1. See up to and including Item 2-1.

2. docker-compose.yml

version: '3.6'
services:
  elasticsearch:
    image: 'docker.elastic.co/elasticsearch/elasticsearch:7.16.2'
    container_name: es_a
    ports:
      - 9200:9200
    environment:
      - node.name="es_a"
      - cluster.name="es-docker-cluster"
      - bootstrap.memory_lock=true
      - discovery.type=single-node
      #- "ES_JAVA_OPTS=-Xms200m -Xmx200m"
    volumes:
      - ./esdata:/usr/share/elasticsearch/data
      - ./eslog:/usr/share/elasticsearch/log
    ulimits:
      memlock:
        soft: -1
        hard: -1
    networks:
      - elastic
    deploy:
      resources:
        limits:
          memory: 1GB  # Use at most 50 MB of RAM
  elasticsearch2:
    image: 'docker.elastic.co/elasticsearch/elasticsearch:7.16.2'
    container_name: es_b
    ports:
      - 9201:9200
    environment:
      - node.name="es_b"
      - cluster.name="es-docker-cluster2"
      - bootstrap.memory_lock=true
      - discovery.type=single-node
      #- "ES_JAVA_OPTS=-Xms200m -Xmx200m"
    volumes:
      - ./esdata2:/usr/share/elasticsearch/data
      - ./eslog2:/usr/share/elasticsearch/log
    ulimits:
      memlock:
        soft: -1
        hard: -1
    networks:
      - elastic2
    deploy:
      resources:
        limits:
          memory: 1GB  # Use at most 50 MB of RAM

volumes:
  esdata:
    driver: local
    driver_opts:
      o: bind
      type: none
      #device: /data
  esdata2:
    driver: local
    driver_opts:
      o: bind
      type: none
      #device: /data2
  eslog:
    driver: local
  eslog2:
    driver: local

networks:
  elastic:
    driver: bridge
  elastic2:
    driver: bridge
# docker-compose -f docker-compose.yml up -d
# docker-compose -f docker-compose.yml stop
# docker-compose -f docker-compose.yml rm

3. Result

# docker-compose -f docker-compose.yml up -d
[+] Running 2/2
 - Container es_a  Started                                                                                                                                                                       2.1s
 - Container es_b  Started
# docker-compose -f docker-compose.yml stop
[+] Running 2/2
 - Container es_a  Stopped                                                                                                                                                                       1.2s
 - Container es_b  Stopped

3-1. 9200

{
  "name" : "\"es_a\"",
  "cluster_name" : "\"es-docker-cluster\"",
  "cluster_uuid" : "KwFTIgGCT7e8ZDNJIau6Jw",
  "version" : {
    "number" : "7.16.2",
    "build_flavor" : "default",
    "build_type" : "docker",
    "build_hash" : "2b937c44140b6559905130a8650c64dbd0879cfb",
    "build_date" : "2021-12-18T19:42:46.604893745Z",
    "build_snapshot" : false,
    "lucene_version" : "8.10.1",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}

3-2. 9201

{
  "name" : "\"es_b\"",
  "cluster_name" : "\"es-docker-cluster2\"",
  "cluster_uuid" : "MZhKEnPuTdu5iNoatWOnQA",
  "version" : {
    "number" : "7.16.2",
    "build_flavor" : "default",
    "build_type" : "docker",
    "build_hash" : "2b937c44140b6559905130a8650c64dbd0879cfb",
    "build_date" : "2021-12-18T19:42:46.604893745Z",
    "build_snapshot" : false,
    "lucene_version" : "8.10.1",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}

 

* If error raised 'Custom Analyzer [nori_korean] failed to find tokenizer under name [nori_tokenizer]'

Install Korean (nori) Analysis Plugin

# sudo bin/elasticsearch-plugin install analysis-nori

The plugin must be installed on every node in the cluster, and each node must be restarted after installation.

 

* Cannot bind to some ports due to permission denied

Run as admin:

net stop winnat
net start winnat

 

Ref.

I have the following docker-compose file : version: "3.3" services: elasticsearch: image: docker.elastic.co/elasticsearch/elasticsearch:6.1.1 volumes: - esdata:/usr/share/
I'm running one elasticsearch with version: '3' services: elasticsearch: build: context: . dockerfile: ./compose/elasticsearch/Dockerfile args: - VERSION=${VERSION} - M...
I'm trying to run multiple versions of ElasticSearch at the same time, should be easy. Here are my commands: docker run -d --rm -p 9250:9200 -p 9350:9300 --name es_5_3_3_integration -e "xpack.sec...
ElasticSearch - cannot run two es docker containers at the same time I'm trying to run 2 services of ElasticSearch using docker-compose.yaml Every time I run docker-compose up -d only one service is
For the last 3 months or so I'm having random errors where I can't bind a specific port where our Identity server is running on my local development workstation. At first I thought it's my broken m...
Docker는 경량 가상화 기술인 리눅스 컨테이너 도구입니다. Windows 10 Home과 Pro에서도 몇 가지 설정을 통해 Docker Desktop으로 리눅스 컨테이너를 사용할 수 있습니다. 이 글에서는 Windows 10에서 Docker Desktop을 설치하는 방법을 총 정리합니다.
WSL이란? Linux용 Windows 하위 시스템을 사용하면 개발자가 기존 가상 머신의 오버헤드 또는 듀얼 부팅 설정 없이 대부분의 명령줄 도구, 유틸리티 및 애플리케이션을 비롯한 GNU/Linux 환경을 수정하지 않고 Windows에서 직접 실행할 수 있습니다. WSL2와 WSL1 비교 WSL 2는 Windows 10, 버전 1903, 빌드 18362 이상에서만 사용할 수 있습니다. 윈도우10에서 WSL2 설치해서 우분투 리눅스를 이용해보자 1. 윈
본 문서에서는 Docker 환경에서 Elasticsearch 7.9 버전을 설치하고 실행하는 방법에 대해서 설명하고 있습니다.
IMPORTANT: No additional bug fixes or documentation updates will be released for this version. For the latest information, see the current release documentation. Elastic Docs› Elasticsearch Plugins and Integrations [6.4]› Analysis Plugins « kuromoji_numbe

 

elasticsearch docker