Docker Community Forums

Share and learn in the Docker community.

Http Proxy .docker/config.json settings ignored by Docker build pull version 19.03.13

I’ve created a .docker/config.json file with the relevant httpProxy and httpsProxy settings. I’ve also got them set in the ENV of the Dockerfile, and in the CLI as --build-arg http_proxy settings, using all three methods the initial pull of the base docker image does not use the proxy, and thus fails.

I’ve also attempted to force the config file to be read properly by specifying --config on the CLI, and confirmed the config file is being sourced by intentionally creating a parse error. Thankfully I also have access to the proxy server, and confirm at no point does the docker build attempt to communicate with the proxy server (tcpdump for packets from the client host)

Has anyone run into this, and does anyone have the fix, I have not done the systemd config changes, as I don’t have root on the client box… that’s the only magical place I haven’t put proxy settings that I’m aware of.

-Karl

On the Docker client, create or edit the file ~/.docker/config.json in the home directory of the user which starts containers. Add JSON such as the following, substituting the type of proxy with httpsProxy or ftpProxy if necessary, and substituting the address and port of the proxy server. You can configure multiple proxy servers at the same time.

You can optionally exclude hosts or ranges from going through the proxy server by setting a noProxy key to one or more comma-separated IP addresses or hosts. Using the * character as a wildcard is supported, as shown in this example.

{
“proxies”:
{
“default”:
{
“httpProxy”: “http://127.0.0.1:3001”,
“httpsProxy”: “http://127.0.0.1:3001”,
“noProxy”: “*.test.example.com,.example2.com”
}
}
}
Save the file.

When you create or start new containers, the environment variables are set automatically within the container.

Hi - thanks for responding, but if you note in my original post, I’ve already done that, and confirmed that it’s being sourced (by intentionally creating a parse error). These settings are not being used by the docker client. A wget on the box hits the proxy as expected (and works) but docker pull times out, and does not attempt to connect to the proxy server.