Linking containers in Docker

docker

Solution

I would say: try ;).

At the moment, docker as no control whatsoever on the process once started as it `execve(3)` without fork. It is not possible to update the env, that's why the links need to be done before the container runs and can't be edited afterward.

Docker will try to reassign the same port to B, but there is no warranty as an other container could be using it.

What do you mean by 'broken'? If you disabled the networking between unlinked container, it should still be working if you stop/start a container.

No, you can't link container across network yet.

Problem

Docker allows you to link containers by name. I have two questions on this: - Supposed `A` (client) is linked to `B` (service), and `B`'s port is exposed dynamically (i.e. the actual host port is determined by Docker, not given by the user). What happens if `B` goes down and is being restarted? - Does Docker update the environment variable on `A`? - Does Docker assign the very same port again to `B`? - Is `A` link to `B` broken? - …? - Besides that, it's quite clear that this works fine if both containers are run on the same host machine. Does linking containers also work across machine boundaries?

Original source