Closed garret closed 5 years ago
There is :) You can have containers use the networking of other containers. See: https://docs.docker.com/engine/reference/run/#network-settings
With the network set to container a container will share the network stack of another container. The other container’s name must be provided in the format of --network container:<name|id>.
If the container exposes some ports/web ui, these ports needs to be added to the vpn container instead as it's the one that controls the network. In this mode the two containers can not run processes on the same port as they would collide (as opposed to two regular containers where this would work as long as you bind them to different host ports)
So just to be clear. You shouldn't need to modify the other image. Just run it with --network container:<id|name>
and add the port binds to the vpn container.
I confirm that is working. I was not expecting to be such easy. Thank you for your fast reply.
I would really like to have another application inside the container so that it can use the advantages of being under the vpn. I was thinking about MLDonkey. I built the container with the default Dockerfile but adding to the end the content taken from this other container -> https://github.com/AngeleToR/docker-mldonkey Everything works but I can see that MLDonkey is not under vpn because the ip is my public one and I can access from outside. Do you know if there is an easy way to do what I am trying to do? Thank you very much in advance.