Skip to Content

Setting up a proxy for Docker

A guide on how to set up a proxy for Docker to manage network traffic effectively.

karchunt

Kar Chun Tan

Creator

Metadata

Tue Nov 04 2025

3 min read

412 words

Setting up a Proxy for Docker

To set up a proxy for Docker, you need to configure the Docker Daemon and the Docker Client to use the proxy server. This is particularly useful in environments where direct internet access is restricted.

You will need to configure

  • Docker Client - to set proxy environment variables for containers started by the Docker CLI.
  • Docker Daemon - to set proxy environment variables for the Docker service itself (for pulling images, etc.).

Configure the Docker Client

Basically, you need to create or modify the config.json file located in the Docker configuration directory (usually ~/.docker/ on Linux and macOS, and %USERPROFILE%\.docker\ on Windows).

The following configuration sets proxy environment variables for Docker containers started by the Docker CLI (client), but does not configure proxy settings for the Docker Daemon itself.

~/.docker/config.json
{ "proxies": { "default": { "httpProxy": "http://your-proxy-server:port", "httpsProxy": "http://your-proxy-server:port", "noProxy": "localhost,.local,127.0.0.1,.example.org,*.yourdomain.com" } } }

After you create or modify the file, when you run Docker commands that start containers, the specified proxy settings will be applied to those containers.

docker run <image> sh -c 'env | grep -i _proxy' # You should see output similar to: http_proxy=http://your-proxy-server:port https_proxy=http://your-proxy-server:port no_proxy=localhost,.local,127.0.0.1,.example.org,*.yourdomain.com

Configure the Docker Daemon

If you want to pull images or interact with registries through a proxy, you need to configure the Docker Daemon to use the proxy server. Normally, Docker Daemon will run as a systemd service on Linux.

  1. Create a directory for Docker service overrides

    sudo mkdir -p /etc/systemd/system/docker.service.d
  2. Create a configuration file (/etc/systemd/system/docker.service.d/http-proxy.conf) for the proxy settings.

    /etc/systemd/system/docker.service.d/http-proxy.conf
    [Service] Environment="HTTP_PROXY=http://your-proxy-server:port" Environment="HTTPS_PROXY=http://your-proxy-server:port" Environment="NO_PROXY=localhost,.local,127.0.0.1,.example.org,*.yourdomain.com"
  3. Reload the systemd daemon and restart Docker

    sudo systemctl daemon-reload sudo systemctl restart docker # or sudo systemctl restart docker.service
  4. Verify the proxy settings are applied to the Docker Daemon

    sudo systemctl show --property=Environment docker

Last updated on