Docker Community Forums

Share and learn in the Docker community.

Access another network's ip device from inside container

Hello,

I’m trying to reach a network printer from inside my app container while using the following setup

  • the host has 2 physical eth ports lan1 and lan2
  • lan1 is used to connect to upstream network
  • a docker container called nat-router is using lan2 to provide downstream network at 10.2.1.x the container setup is a combination of dnsmasq, pipework script and ip tables
  • the nat-router container ip is 172.19.0.2
  • the “printer” container ip is 172.25.0.104

my aim is to have the network printer available on the downstream network, for example at 10.2.1.5, however, I was unable to connect to it from inside the printer container.

this is the output of “ip r” on respective containers.

root@9f7cb70cf3d4:/# ip r
default via 172.19.0.1 dev eth0
10.1.2.0/24 dev eth1 proto kernel scope link src 10.1.2.1
172.19.0.0/16 dev eth0 proto kernel scope link src 172.19.0.2

root@0fb1fbfa5c46:/# ip r
default via 172.25.0.1 dev eth0
172.25.0.0/24 dev eth0 proto kernel scope link src 172.25.0.104

Am I correct to think the 10.1.2 route should be added to the printing container for this to work ? What would be the best way to achieve that ?