I originally stated I didn't want to use containers, but found the iptables
/ulogd
solution to be quite fiddly to get it to work. Since it may not just be me doing this in future, I did eventually elect to use containers to do it.
In my case, I wanted to test a UI and an API, which use an nginx
and mysql
running on the host itself. Getting traffic from nginx
to the container was pretty easy (using port mapping). Getting traffic out of the UI container into the API container is pretty easy (use standard docker networking, where the other container's port appears on localhost
).
Getting from the API to mysql
proved to be trickier. Docker really doesn't want to let containers talk to localhost
on their host. It will quite easily talk to the network-facing interface though (via the 172.17.0.x
IP addresses assigned to Docker containers). Making mysql
listen on the network interface instead of localhost
completes the "circuit".
Once it's all working, it's easy to see all the Docker traffic by watching the Docker interface tcpdump -ni docker0
.
It seems then, there are no quick and simple solutions to this problem, and only a couple of potential solutions.