How can I let all my docker containers use my proxy?
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Puzzle Game Looping
--
Chapters
00:00 How Can I Let All My Docker Containers Use My Proxy?
01:06 Accepted Answer Score 5
01:52 Answer 2 Score 1
02:31 Thank you
--
Full question
https://superuser.com/questions/890196/h...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#proxy #docker
#avk47
ACCEPTED ANSWER
Score 5
Host server runs a container running a proxy (squid, in this case) that can do transparent proxying. That container has some iptables rules that NAT traffic into the proxy server - this means that container needs to run in privileged mode.
Host server also contains (and here's the magic) ip route table entries that re-route all traffic from any container but the proxy that was destined for port 80, through the proxy container.
That last bit essentially means that for port 80 traffic, the route from container to the rest of the world goes through the proxy container - giving it the chance to NAT and transparent proxy.
ANSWER 2
Score 1
The Configure the Docker client official documentation shows how to easily solve this problem.
Edit the ~/.docker/config.json
(or %USERPROFILE%\.docker\config.json
) file and add the following JSON snippet:
{
"proxies": {
"default": {
"httpProxy": "http://localhost:3128",
"httpsProxy": "https://localhost:3128"
}
}
}
This solved my issue where running apt udpate
inside a debian docker container would fail. After adding the proxy settings in that json file and starting a new docker container apt update
started to work.