I am working on a Docker setup using mitmproxy for network logging, to allow a containerized Docker build environment to get all its network accesses audited. In this setup, build-container
is the container doing the build, and proxy-client
is the container with the proxy WireGuard tunnel (and a default route sending all traffic into that tunnel).
I have been able to get it working using this kind of technique:
docker container run --detach --cap-add NET_ADMIN --tty -it --network container:proxy-client --name build-container build-container-image
This works great; the proxy-client
container has the tunnelling network setup, and the build-container
just uses that tunnelling network.
But I now need to deploy this in a system where build-container
gets created first, before the proxy-client
container. (The build-container
setup is part of a pre-existing system that I can’t easily change.)
Fine, I thought, I’ll just remove the system-created build-container
from its “birth network”, and I’ll add it to the proxy-client
container’s network with:
docker network connect container:proxy-client build-container
Unfortunately, this doesn’t work. The error is:
Error response from daemon: network container:proxy-client not found
It seems that docker network connect
doesn’t support the container:[container-name]
syntax for specifying another container’s network. But I haven’t been able to find any definitive answer to this in Docker documentation.
Is it the case that the container:[container-name]
network syntax only works with docker run
? Is there any other way to dynamically add a container to another container’s network?
(I know I could possibly create a second bridge network, or something, but I’m not too confident in being able to make that work with the WireGuard setup I have working today.)
Thanks!