10

I am trying to run a Docker container as a router between a private (--internal) Docker network and the predefined host network. This means the container needs to have two network interfaces: One "outside" interface, that can access all host IP addresses, and one "inside" interface, that acts as a gateway for the containers in the internal Docker network

The router container itself will then NAT network traffic from/to containers.

I have not found a way to configure Docker to run the container with those two interfaces. The closest I could get is having two bridge interfaces assigned, which is not exactly what I need.

Trying to connect manually results in an error:

# docker network connect host root_router_1
Error response from daemon: Container cannot be disconnected from host network or connected to host network

Can anybody show me how to achieve this, preferably even whith Docker Compose?

  • did you find answer to this situation ? We are having similar problem statement and error. – Pun Mum Apr 7 '18 at 5:50
  • @PunMum Unfortunately not. We ended up connecting all containers directly to the host network and configuring the IPs inside the containers. – Hexaholic Apr 9 '18 at 7:37
2

According to this Q&A on github:

The host network is special. You have to use network_mode: host on the service

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.