Docker Community Forums

Share and learn in the Docker community.

Bind Docker container to specific NIC?


Hello all!
We are trying to setup a system with four instances of the same container, but it’s vital that all network traffic (incoming AND outgoing) for each container is restricted to a specific NIC on the host (container_1->eno1 container_2->eno2, etc…). I did get the containers to bind to the IP addresses (in our docker-compose.yml) with

- “”

But that only affected incoming traffic, all outbound traffic for all containers was primarily routed through eno1, which was unacceptable. I know that we can do this with VMs, but Docker would play much nicer with our config management. Does anyone know how to do this with Docker, and if so, how we would go about doing that?

OS: Debian Buster (10)
Docker 18.09.2

(Ove "Lime" Lindström) #2

That is not really a Docker-issue but you need to do the manipulation on the host using something like Pipework or by using the ip netns commands in Linux.

I found this one that might help you get started.


Ah, alright. I wasn’t sure, but I figured that I would ask in case there was a combination of option flags that I was missing.
Thanks for your help!