gpt4 book ai didi

docker - docker-compose副本主机名

转载 作者:行者123 更新时间:2023-12-02 19:36:42 24 4
gpt4 key购买 nike

我正在尝试使用docker-compose scale graylog-es-slave=2添加具有副本的群集,但对于版本3的Dockerfile,与Docker compose and hostname不同

我正在尝试做的工作ix弄清楚如何获取副本集中的特定节点

这是我尝试过的

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
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

最佳答案

代替.,使用_(下划线),并添加项目名称的前缀(保存您的docker-compose.yml的目录,我假设它是liberty-docker_graylog):

ping liberty-docker_graylog-es-slave_1

您会看到这样做 network ls,搜索正确的网络,然后搜索 docker network inspect network_id

关于docker - docker-compose副本主机名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44331120/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com