Docker Community Forums

Share and learn in the Docker community.

DNS discovery different between v1 and v2 of docker-compose.yml


(Jgielstra) #1

Expected behavior

The dns resolution of services is the same between v1 and v2 of docker compose…

On docker > 1.9 --link shouldn’t be required and /etc/resolv.conf with docker internal DNS 127.0.0.11 should resolve services defined in the docker-compose.yml.

Works the same regardless of docker-compose file version 1 or 2

Actual behavior

docker-compose v1 doesn’t resolve services unless I explicitly link them via --link.

docker-compose v2 works as expected

Information

  • the output of:

    • pinata diagnose -u on OSX

       ➜  temp pinata diagnose -u
       OS X: version 10.11.3 (build: 15D21)
       Docker.app: version v1.11.0-beta8.2
       Running diagnostic tests:
       [OK]      docker-cli
       [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/20160420-213205.tar.gz
       Most specific failure is: No error was detected
       Your unique id is: 2E1B7AB7-BA7B-4B49-A5A7-0D969968EB05
       Please quote this in all correspondence.
      
  • a reproducible case if this is a bug, Dockerfiles FTW
    see below

  • host distribution and version ( OSX 10.10.x, OSX 10.11.x, Windows, etc )

    	➜  temp uname -a
    	Darwin <hostname> 15.3.0 Darwin Kernel Version 15.3.0: Thu Dec 10 18:40:58 PST 2015; root:xnu-3248.30.4~1/RELEASE_X86_64 x86_64
    

Steps to reproduce the behavior

  1. Copy the two compose files

  2. Execute the compose files below via docker-compose up

  3. v1 will fail with
    ➜ temp docker-compose -f docker-compose-v1.yml up

    Starting temp_service2_1
    Starting temp_service1_1
    Attaching to temp_service1_1, temp_service2_1
    service2_1 | nc: bad address 'service1’
    temp_service2_1 exited with code 1

v2 will succeed

➜ temp docker-compose -f docker-compose-v2.yml up
Recreating temp_service2_1
Recreating temp_service1_1
Attaching to temp_service2_1, temp_service1_1
service1_1 | HELLO 1
temp_service1_1 exited with code 0
temp_service2_1 exited with code 0

docker-compose.yml V1

service1:
 image: alpine
 command: nc -l -p 123
service2:
 image: alpine
 command: sh -c "echo \"HELLO 1\" | nc service1 123"

docker-compose.yml v2

version: "2"
services:
 service1:
  image: alpine
  command: nc -l -p 123
 service2:
  image: alpine
  command: sh -c "echo \"HELLO 1\" | nc service1 123"