- Docker Client — sets proxy environment variables for containers started by the Docker CLI.
- Docker Daemon — sets proxy environment variables for the Docker service itself (for pulling images, etc.).
Create or modify the
config.json file located in the Docker configuration directory (~/.docker/ on Linux/macOS, or %USERPROFILE%\.docker\ on Windows).The following configuration sets proxy environment variables for Docker containers started by the Docker CLI but does not configure proxy settings for the Docker Daemon itself.
{
"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"
}
}
}
If you don’t want to configure the proxy globally in
config.json, you can set it inline when running or building containers:Do not use
ENV in a Dockerfile to set proxy variables — it will bake the proxy settings into the image, which is typically undesirable.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
If you want to pull images or interact with registries through a proxy, configure the Docker Daemon. On Linux, Docker Daemon runs as a systemd service.
/etc/systemd/system/docker.service.d/http-proxy.conf