Now both containers are connected to the same network.
How can I create iptable rules or gateway to guide all the traffic from app container to proxy container and then to the external web (without changing or creating iptable rules in host…)?
I am completely new in routing, linux gateway and iptables. I want to transfer my system from virtualbox to docker (I have created such system in virtualbox with app running in internal network (combining some tutorials)).
There is only one iptables setup and it’s the host’s. Containers don’t have their own firewall rules.
Most Linux programs honor an http_proxy environment variable (by convention all lowercase) and you can set this from the Docker Compose file; that may or may not achieve what you want. In this context you could set it to the name of the proxy container running on the locally-defined Docker network.
Containers are created using linux distros and it is possible to create iptables rules in linux to route traffic. Iptable commands example iptable -L is allowed when using container in --privileged mode.
I have not created any rules to test if iptable rules are working or not.
From this reply I understand that docker container does not follow rules that are created in container or did I misunderstood it? Why can’t users create firewall rules?
I’m pretty sure you’re looking at the host’s firewall rules. --privileged says “turn off many of the basic security knobs that prevent containers from breaking the host” and this is one of them.
In proxy11:
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
In client11:
ip route del default
ip route add default via 10.6.0.6
I can ping google.com in client11, but I can not install packages or update linux. Why I can ping, but can not install packages?
Command ip route output in Client11: default via 10.6.0.6 dev eth0 10.6.0.0/16 dev eth0 proto kernel scope link src 10.6.0.5
output of iptables -nvL -t nat command in Client11:
hi.everybody
Im new in docker
I have a container on centos7 machine in workstation.when I want to use scp from another machine(centos6.8) on weorkstation to this container I face this :
ssh: connect to host 172.17.0.2 port 22: No route to host
lost connection
both container and machine ping eche other
could anybodey help me ?
Iwill be thankfull