Whenever you link Docker containers together, the question comes up how to access services provided by the linked container: the actual IP address of the container is not static and cannot be guessed beforehand. Sure, the IP address can be looked up by the environment variables (
$ env), but not all programs can be modfied to understand these variables. This is even more true for containers which you receive from the Docker registry.
Thus the quickest way is to define a host name along the
docker run. The container can be reached afterwards via that exact name.
$ docker run --hostname=db-container -d postgres ... $ docker run -it --link db:dbtestlink centos /bin/bash # ping db-container PING dbtestlink (172.17.0.13) 56(84) bytes of data. 64 bytes from dbtestlink (172.17.0.13): icmp_seq=1 ttl=64 time=0.178 ms