Do --link work both ways?

If I create an Nginx container (for instance) and then a container hosting a node app (for instance) can I create the link from the node app so that Nginx can host it (and it appear in the Nginx hosts file) or do I have to bring the Nginx container down, add the link and start it again?
If the latter is true, what is the solution to hosting multiple apps through one Nginx container that cant know about the others until they are created?

I would not use link to do it. My way is to run a dnsmasq instance on the host, and automatically update DNS record (A records with values of containers’ names) using this script. Then, start any containers which need to know others with --dns HOST_ADDRESS option.

1 Like

You could use Consul to store the data about the containers, registrator to announce new containers to Consul, and confd to reconfigure nginx everytime a container gets shutdown or started.