Reputation: 258
From the official document, the static ip address should work with docker compose v3 + docker swarm. But I cannot make it work.
This is my docker compose 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'
I use docker stack up -c xxx.yml test
to deploy. I found the ip of the created containers are 10.1.0.3, 10.1.0.5, ...
Upvotes: 13
Views: 6448
Reputation: 1305
That works in non-swarm mode, but not in swarm mode. You may subscribe to this ticket to find out when/if support is added.
At the moment, there's an anecdotal claim of a workaround, but nobody else seems to have corroborated it.
Upvotes: 7