Linking between containers in a version 2 docker-compose file is not working.
Only when using the 'old' version 1 format, I do see the link in /etc/hosts of the container.
I have the following basic version 2 docker-compose.yml file.
version: '2' services: my-app: image: tomcat:8.0 container_name: my-app1 links: - my-redis my-redis: image: redis container_name: my-redis1
When I run the following command:
docker-compose up -d
I see that two containers are started, but no link is created in the /etc/hosts file:
docker exec -it my-app1 cat /etc/hosts
127.0.0.1 localhost ::1 localhost ip6-localhost ip6-loopback fe00::0 ip6-localnet ff00::0 ip6-mcastprefix ff02::1 ip6-allnodes ff02::2 ip6-allrouters 172.18.0.3 2abb84ccada9
From 'my-app1' I can ping the other container using the IP address of 'my-redis1', but I cannot 'ping my-redis1' (based on a name).
What could be the problem here?
Additional information:
- Docker version 1.10.0, build 590d5108
- docker-compose version 1.6.0, build d99cad6
- Linux kernel: 4.3.5-300.fc23.x86_64
/etc/hosts
it uses an embedded DNS server. There is a known issue with the dns server and firewald running on the host. That might be causing the problem. You should be able to ping using both the container name and the service name. – dnephin