12

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

PunCha
  • 229
  • 2
  • 9
  • The cause is using the `docker swarm`. In simply docker-compose you can use as you wrote. But in swarm you can't (for now). I also find out the solution to set the static IP – Nikita_kharkov_ua Sep 21 '17 at 13:37

1 Answers1

5

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.

Jamie Jackson
  • 965
  • 2
  • 16
  • 29