Suggestions? docker-compose embedded dns causes any lookup to fail

I’m looking for suggestions to deal with a tricky dns problem. I’ve got a very simple scenario where any dns lookup with a docker compose project fails, while analogous commands with plain docker work.

I’ve setup with the relevant code, but I suspect that this might be host/kernel specific due to it not reproducing on other systems I have. The problematic host is Ubuntu 14.04.1, while it works on an OSX 10.11.6 host.

Here’s what happens:

I have a docker-compose file that runs two containers, one which pings and one which cats /etc/resolv.conf.

version: "2"
    image: python:3.6-alpine
    command: "ping -c 1"
    image: python:3.6-alpine
    command: "cat /etc/resolv.conf"

The output looks something like this:

options ndots:2

Creating pingtest_ping_1
Creating pingtest_dns_1
Attaching to pingtest_ping_1, pingtest_dns_1
dns_1   | search
dns_1   | nameserver
dns_1   | options ndots:2 ndots:0
pingtest_dns_1 exited with code 0
ping_1  | ping: bad address ''
pingtest_ping_1 exited with code 1

But, if I run basically identical commands with plain docker, they both succeed.

docker run --rm python:3.6-alpine ping -c 1
docker run --rm python:3.6-alpine cat /etc/resolv.conf

PING ( 56 data bytes
64 bytes from seq=0 ttl=50 time=3.913 ms

--- ping statistics ---
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max = 3.913/3.913/3.913 ms
options ndots:2

I’ve already tried hardcoding dns settings in my docker-compose file, the end result is the same. Any ideas/suggestions?


Version info:
$ sudo docker --version
Docker version 17.03.0-ce, build 60ccb22
$ sudo docker-compose --version
docker-compose version 1.11.2, build dfed245