To my understanding, linking is about establishing implicit port connection to source container in recipient container, thus avoid explicitly exposing source port, or mapping host port to the source container port. Is this correct?
But in the examples using linking in the tutorial, there isn’t a source port specified when starting the source container:
Create the source container using postgres:
docker run -d --name database postgres
a ‘docker ps’ does show the port 5432, though no mapping.
Create the recipient container and link it to source container:
docker run -d -P --name website --link database:db nginx
My question is: how does the recipient container know which port on the source container to connect to? why is ‘–name’ declaration enough to provide direct connection?