静态 IP 地址在 docker compose v3 中不起作用
Static IP address doesn't work in docker compose v3
从官方文档来看,静态IP地址应该与docker compose v3 + docker swarm一起使用。但是我做不到。
这是我的 docker 编写 yaml:
version: '3'
networks:
test:
ipam:
driver: default
config:
- subnet: 10.1.0.0/24
services:
one:
image: mongo
networks:
test:
ipv4_address: '10.1.0.100'
two:
image: mongo
networks:
test:
ipv4_address: '10.1.0.101'
three:
image: mongo
networks:
test:
ipv4_address: '10.1.0.102'
我使用docker stack up -c xxx.yml test
部署。我发现创建的容器的ip是10.1.0.3, 10.1.0.5, ...
在非集群模式下有效,但在集群模式下无效。您可以订阅 this ticket 以了解已添加 when/if 支持。
目前,有一个 anecdotal claim of a workaround,但似乎没有其他人证实它。
从官方文档来看,静态IP地址应该与docker compose v3 + docker swarm一起使用。但是我做不到。
这是我的 docker 编写 yaml:
version: '3'
networks:
test:
ipam:
driver: default
config:
- subnet: 10.1.0.0/24
services:
one:
image: mongo
networks:
test:
ipv4_address: '10.1.0.100'
two:
image: mongo
networks:
test:
ipv4_address: '10.1.0.101'
three:
image: mongo
networks:
test:
ipv4_address: '10.1.0.102'
我使用docker stack up -c xxx.yml test
部署。我发现创建的容器的ip是10.1.0.3, 10.1.0.5, ...
在非集群模式下有效,但在集群模式下无效。您可以订阅 this ticket 以了解已添加 when/if 支持。
目前,有一个 anecdotal claim of a workaround,但似乎没有其他人证实它。