Configure Docker Daemon to Use HTTP Proxy

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

Restart Docker:

# systemctl daemon-reload
# systemctl restart docker


# systemctl show --property=Environment docker

Leave a Reply

Your email address will not be published.