Docker build error: “could not connect to server” (behind proxy)

£可爱£侵袭症+ 提交于 2019-12-06 02:16:51

I finally managed to solve this problem, and the culprit was my setting in the CNTLM. For a background story, please check this post.

The root cause of this problem is that the docker container could not access the internet from inside the VM due to wrong IP setting inside the CNTLM.ini.

Normally CNTLM listens to 127.0.0.1:3128 by default to forward the proxy. I followed the default, and thus set the proxy setting on Docker (for the daemon - through the GUI, and for the container - through config.json) is also set into that address and port. It turns out that this "localhost" does not apply to the VM where docker sits, since the VM has its own localhost. Long story short, the solution is to change that address into dockerNAT IP address (10.0.75.1:3128) in all of the following locations:

  • CNTLM.ini (on the Listen line. Actually if we use CNTLM for other purposes as well, it is possible to supply more than one Listen line)
  • Docker daemon's proxy (through the Docker setting GUI)
  • Docker container config.json (usually in C:\Users\<username>\.docker), by adding the following lines:

    "proxies":
     {
       "default":
       {
         "httpProxy": "http://10.0.75.1:3128",
         "httpsProxy": "http://10.0.75.1:3128",
         "noProxy": <your no_proxy>
       }
     }
    

also check these related posts:

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!