Configure the docker daemon to use a proxy

Configure the docker daemon to use a proxy

Content #

Daemon configuration #

You may configure proxy behavior for the daemon in the daemon.json file, or using CLI flags for the –http-proxy or –https-proxy flags for the dockerd command. Configuration using daemon.json is recommended.

{
    "proxies": {
        "http-proxy": "http://proxy.example.com:3128",
        "https-proxy": "https://proxy.example.com:3129",
        "no-proxy": "*.test.example.com,.example.org,127.0.0.0/8"
    }
}

After changing the configuration file, restart the daemon for the proxy

$ sudo systemctl restart docker

Environment variables #

The Docker daemon checks the following environment variables in its start-up environment to configure proxy behavior:

  • http_proxy
  • https_proxy
  • no_proxy

systemd unit file #

[Service]
Environment="HTTP_PROXY=http://proxy.example.com:3128"
Environment="HTTPS_PROXY=https://proxy.example.com:3129"
$ sudo systemctl show --property=Environment docker

From #