Static IP does not work in docker compose v3

From the official doc, the static IP address should work with docker creating swarm v3 + dockers. But I can’t make it work.

This is my docker creating 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 testfor deployment. I found the ip created containers 10.1.0.3, 10.1.0.5, ...

+6
source share
1 answer

This works in non-swarm mode, but not in swarm mode. You can sign up for this ticket to find out when support is added.

At the moment, there is an anonymous statement about a workaround , but no one else seems to have confirmed it.

+1
source

All Articles