Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
All network links not available when using docker-compose run #4052
It appears that when using
Note that when use with
Here is an example docker-compose (v2) which when used with
version: '2' networks: internal: driver: bridge services: slave: command: "ash -c 'sleep 1; ping master'" image: busybox networks: - internal master: command: "ping slave" depends_on: - slave image: busybox networks: - internal
When this is run with
$ docker-compose up Creating network "my_internal" with driver "bridge" Creating my_slave_1 Creating my_master_1 Attaching to my_slave_1, my_master_1 master_1 | PING slave (172.19.0.2): 56 data bytes master_1 | 64 bytes from 172.19.0.2: seq=0 ttl=64 time=0.064 ms slave_1 | PING master (172.19.0.3): 56 data bytes slave_1 | 64 bytes from 172.19.0.3: seq=0 ttl=64 time=0.146 ms master_1 | 64 bytes from 172.19.0.2: seq=1 ttl=64 time=0.126 ms slave_1 | 64 bytes from 172.19.0.3: seq=1 ttl=64 time=0.127 ms master_1 | 64 bytes from 172.19.0.2: seq=2 ttl=64 time=0.143 ms slave_1 | 64 bytes from 172.19.0.3: seq=2 ttl=64 time=0.153 ms master_1 | 64 bytes from 172.19.0.2: seq=3 ttl=64 time=0.058 ms slave_1 | 64 bytes from 172.19.0.3: seq=3 ttl=64 time=0.130 ms master_1 | 64 bytes from 172.19.0.2: seq=4 ttl=64 time=0.157 ms slave_1 | 64 bytes from 172.19.0.3: seq=4 ttl=64 time=0.142 ms ^CGracefully stopping... (press Ctrl+C again to force) Stopping my_master_1 ... done Stopping my_slave_1 ... done
Same thing run with
$ docker-compose run --rm --service-ports master Creating network "my_internal" with driver "bridge" Creating my_slave_1 PING slave (172.19.0.2): 56 data bytes 64 bytes from 172.19.0.2: seq=0 ttl=64 time=0.090 ms ^C --- slave ping statistics --- 26 packets transmitted, 1 packets received, 96% packet loss round-trip min/avg/max = 0.090/0.090/0.090 ms $ docker logs my_slave_1 ping: bad address 'master'
Obviously I can't create dependency cycles using
@johnculviner the workaround is to run something like
@johanbrandhorst thanks for that! I ended up going this route which worked great for isolated bi-directional container communication (required for certain types of selenium tests). Each container is addressable within the container via DNS which is just their respective container names. Hope this helps someone setup something similar:
and then running this command (or something similar) to kick of the tests and get stdout/err as I need.
Agreed. I've come to the same hack independently (the
Ps. #4811 (looks like someone is working on it -- there is an open PR)
referenced this issue
Sep 1, 2017
Had the same issue (#5147)
Could somebody confirm it working?
Desided to go without networking for now, but I had problem that all dependencies couldn't access main app container, after half of a night googling I've found that --name should be passed or else hostname of container name won't work. This is also not documented :(
@johanbrandhorst it's submitted feel free to add something in there. I really think this should be pushed forward also as --name and --use-aliases parameters together with --service-ports which are all undocumented almost at all.
referenced this issue
Apr 9, 2018
I was running the ubuntu version of docker holded in this respository (docker.io 18.06.0). I removed that version an install docker.io using apt-get install docker.io. So now I have this version:
Containers running with docker-compose doesn't have the file resolv.conf with the dns consiured as expected, but, each container can access Internet. I think that change solve mi problem.