Can --link be made more robust for ip/port mappings

I was considering using --link to link up default Discourse data and web containers.

Trivially the trick you would follow is:

docker run -d -p 80 --name data ubuntu /bin/sleep 999999
docker run -it --rm  --name web --link data ubuntu /bin/bash

All is good in the web container, if I run:

# env
...
DATA_PORT_80_TCP=tcp://172.17.0.79:80

Which is fantastic

BUT… if I restart my data container it gets a new IP.

Now DATA_PORT_80_TCP does not point at the correct IP address so effectively my environment is in a broken state.

My suggestions / feature request

  • Can an extra var be added that forces all depending containers to restart if a parent linked container restarts (which would force the env refresh)

  • Can/will docker act as a DNS server to provide a proper lookup for the IP for depending containers?

As it is … this link by ip/port feature is mostly useless to us as it is not resilient or restarts and can lead to very bad and hard to troubleshoot environments.

have you played with the experimental networking code?

Not yet, I may have a go playing with libnetwork