Answer the question
In order to leave comments, you need to log in
Docker internet access through another container?
How to create a network via docker-compose between two containers so that container A can access the internet through container B?
Container B will have redsocks which will collect all traffic coming into it and send it to the proxy server.
Answer the question
In order to leave comments, you need to log in
If you need to wrap traffic not through a regular gateway in a regular docker network, but through one of the containers, then this can still be done using a system of props and stretch marks.
1. Add to container configuration:
cap_add:
- NET_ADMIN
ip route replace default via IP_другого_контейнера
ip route add default via `dig +short router`
sysctl -w net.ipv4.ip_forward=1
iptables -t nat -A POSTROUTING -s 172.18.0.0/24 -j MASQUERADE
network=$(ip route list|grep scope\ link|cut -d ' ' -f 1)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question