Archimedes Trajano
Archimedes Trajano

Reputation: 41220

docker-compose replica hostname

I am trying to add a cluster with replicas using docker-compose scale graylog-es-slave=2 but for a version 3 Dockerfile unlike Docker compose and hostname

What I am trying to do ix figure out how to get the specific node in the replica set

Here is what I have tried

D:\p\liberty-docker>docker exec 706814bf33b2 ping graylog-es-slave -c 2
PING graylog-es-slave (172.19.0.4): 56 data bytes
64 bytes from 172.19.0.4: icmp_seq=0 ttl=64 time=0.067 ms
64 bytes from 172.19.0.4: icmp_seq=1 ttl=64 time=0.104 ms
--- graylog-es-slave ping statistics ---
2 packets transmitted, 2 packets received, 0% packet loss
round-trip min/avg/max/stddev = 0.067/0.085/0.104/0.000 ms

D:\p\liberty-docker>docker exec 706814bf33b2 ping graylog-es-slave.1 -c 2
ping: unknown host

D:\p\liberty-docker>docker exec 706814bf33b2 ping graylog-es-slave_1 -c 2
ping: unknown host

The docker-compose.yml

version: 3
service:
  graylog-es-slave:
    image: elasticsearch:2
    command: "elasticsearch -Des.cluster.name='graylog'"
    environment:
      ES_HEAP_SIZE: 2g
    deploy:
      replicas: 2 <-- this is ignored on docker-compose just putting it here for completeness

Upvotes: 1

Views: 5546

Answers (1)

Robert
Robert

Reputation: 36733

Instead of ., use _ (underscore), and add the prefix of the project name (the directory that holds your docker-compose.yml, I assume that it is liberty-docker_graylog):

ping liberty-docker_graylog-es-slave_1

You can see that doing network ls, search for the right network, then docker network inspect network_id.

Upvotes: 3

Related Questions