2

I'd like to run docker cluster on multiple hosts using docker / docker-compose

I could define 3 containers es1, es2, es3 and then run each containers in each host I guess. (I'm not sure how I'll make them discover each other)

Of course, it'll be huge pain to start/restart cluster sshing onto 3 machines.

is it possible to manage multi-host docker somehow?

https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html#docker-compose-file gives an example but it runs on single host I believe

version: '2.2'
services:
  es01:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.5.1
    container_name: es01
    environment:
      - node.name=es01
      - cluster.name=es-docker-cluster
      - discovery.seed_hosts=es02,es03
      - cluster.initial_master_nodes=es01,es02,es03
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
    ulimits:
      memlock:
        soft: -1
        hard: -1
    volumes:
      - data01:/usr/share/elasticsearch/data
    ports:
      - 9200:9200
    networks:
      - elastic
  es02:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.5.1
    container_name: es02
    environment:
      - node.name=es02
      - cluster.name=es-docker-cluster
      - discovery.seed_hosts=es01,es03
      - cluster.initial_master_nodes=es01,es02,es03
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
    ulimits:
      memlock:
        soft: -1
        hard: -1
    volumes:
      - data02:/usr/share/elasticsearch/data
    networks:
      - elastic
  es03:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.5.1
    container_name: es03
    environment:
      - node.name=es03
      - cluster.name=es-docker-cluster
      - discovery.seed_hosts=es01,es02
      - cluster.initial_master_nodes=es01,es02,es03
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
    ulimits:
      memlock:
        soft: -1
        hard: -1
    volumes:
      - data03:/usr/share/elasticsearch/data
    networks:
      - elastic

volumes:
  data01:
    driver: local
  data02:
    driver: local
  data03:
    driver: local

networks:
  elastic:
    driver: bridge
eugene
  • 39,839
  • 68
  • 255
  • 489
  • 3
    Docker on its own can't natively manage containers on multiple hosts; cluster managers like Swarm or Kubernetes are designed for this. Given the storage requirements you still might consider running ES directly on a node and not in Docker and using a system management tool like Ansible or Chef to manage it. – David Maze Jan 03 '20 at 10:54
  • have a look here https://stackoverflow.com/questions/40737389/docker-compose-deploying-service-in-multiple-hosts – Lupanoide Jan 03 '20 at 11:13

0 Answers0