Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't pull docker image behind a proxy

I am trying to pull images behind a proxy.

  1. I've setted the docker config file : ~/.docker/config.json :
{
 "proxies":
 {
   "default":
   {
     "httpProxy": "...",
     "httpsProxy": "..."
   }
 }
}
  1. Setted $DOCKER_CONFIG as [asbolute_path]/my_home/.docker

  2. Restarted docker daemon: sudo systemctl restart docker

Not working.

Documentation I followed :

https://docs.docker.com/network/proxy/#configure-the-docker-client

Any tips ?

like image 601
emilie zawadzki Avatar asked Mar 21 '26 14:03

emilie zawadzki


1 Answers

You referenced to a wrong document, the method mentioned in configure-the-docker-client is all about how to set default proxy for containers, not for docker daemon, while docker daemon is the program who responsible for pull docker image.

The correct step is as next:

  1. mkdir -p /etc/systemd/system/docker.service.d

  2. new a file /etc/systemd/system/docker.service.d/http-proxy.conf with something like next:

    [Service]
    Environment="HTTP_PROXY=http://proxy.example.com:80"
    Environment="HTTPS_PROXY=https://proxy.example.com:443"
    Environment="NO_PROXY=localhost,127.0.0.1,docker-registry.example.com,.corp"
    
  3. restart the docker daemon with next:

    systemctl daemon-reload
    systemctl restart docker
    

NOTE: above things need be executed with sudo/root.

You should see next after check docker info if you are successful:

$ docker info | grep Proxy
 HTTP Proxy: http://proxy.example.com:80
 HTTPS Proxy: https://proxy.example.com:443
 No Proxy: localhost,127.0.0.1,docker-registry.example.com,.corp

Details refers to official document.

like image 127
atline Avatar answered Mar 24 '26 13:03

atline