Linking with docker-compose fails

Expected behavior

Restarting containers (consul) should have no impact on the cluster.

Actual behavior

Restarting containers that are linked fails and containers are down.

Information

  • the output of:
    • pinata diagnose -u on OSX
    • DockerDebugInfo.ps1 using Powershell on Windows
  • a reproducible case if this is a bug, Dockerfiles FTW
  • page URL if this is a docs issue or the name of a man page
  • host distribution and version ( OSX 10.10.x, OSX 10.11.x, Windows, etc )
OS X: version 10.11.5 (build: 15F34)
Docker.app: version v1.11.1-beta13.1
Running diagnostic tests:
[OK]      Moby booted
[OK]      driver.amd64-linux
[OK]      vmnetd
[OK]      osxfs
[OK]      db
[OK]      slirp
[OK]      menubar
[OK]      environment
[OK]      Docker
[OK]      VT-x
Docker logs are being collected into /tmp/20160602-152719.tar.gz
Most specific failure is: No error was detected
Your unique id is: 1CED7314-4344-4E07-B8F3-22952D94343C
Please quote this in all correspondence.

Steps to reproduce the behavior

compose file:

node1:
  image: progrium/consul
  command: -server -bootstrap-expect 3

node2:
  image: progrium/consul
  command: -server -join node1
  links:
    - node1

node3:
  container_name: node3
  image: progrium/consul
  command: -server -join node1
  links:
    - node1
  1. docker-compose up (might fail)
  2. docker restart consul_server2 or docker restart consul_server3
  3. Restarted container won’t connect with consul_server1
  4. node3 | ==> lookup consul_server1: no such host

Using hardcoded consul_server1 ip works fine, you can restart linked containers without any issues.

It’ll work for:

node1:
  image: progrium/consul
  command: -server -bootstrap-expect 3

node2:
  image: progrium/consul
  command: -server -join 172.17.0.2
  links:
    - node1

node3:
  container_name: node3
  image: progrium/consul
  command: -server -join 172.17.0.2
  links:
    - node1