Docker Community Forums

Share and learn in the Docker community.

Allowing docker containers to communicate with internet using a container as a gateway

(Bannup) #1

Below is my configuration of my docker containers


nw1: This is a private network containers in this network cannot access the internet (ping google doesn’t work)

bridge:This is not a private network and is the default network of a container and containers in this network can access the internet (ping google works)

containers :

vm1_nw1:This container is connected to nw1(private network nw1)

vm2_nw1:This conatiner is connected to nw1(private network nw1)

ext_world_vm :This container is connected to both networks(nw1,bridge)

with the below configuration i was able to ssh from ext_world_vm to vm1_nw1 and vm2_nw1 i.e the containers vm1_nw1 and vm2_nw1 can be accessed using ext_world_vm container

The following is my problem statement

now i want to configure these containers as follows

The containers vm1_nw1,vm2_nw1 must be able to access the internet via ext_world_vm (i.e ext_world_vm must act as gateway for vm1_nw1,vm2_nw1 ping google should work from vm1_nw1,vm2_nw1)