Running Docker inside a semi-isolated corporate network.
The Problem
We’ve deployed Docker inside a corporate network where direct access to the Internet is not allowed, and we must use a Squid HTTP proxy http://proxy.example.test:3128 for all outbound connections.
The Solution
Docker can use the HTTP_PROXY, HTTPS_PROXY and NO_PROXY environmental variables to configure proxy behaviour.
Docker with HTTP Proxy
Create a systemd directory for the docker service:
# mkdir -p /etc/systemd/system/docker.service.d
Create a file http-proxy.conf
and add environment variables. Do not proxy internal requests.
# cat > /etc/systemd/system/docker.service.d/http-proxy.conf << EOF [Service] Environment="HTTP_PROXY=http://proxy.example.test:3128" Environment="HTTPS_PROXY=http://proxy.example.test:3128" Environment="NO_PROXY=127.0.0.1,localhost" EOF
Restart Docker:
# systemctl daemon-reload # systemctl restart docker
Verify:
# systemctl show --property=Environment docker