深圳市住房和城乡建设局网站,软件汇,自建个网站怎么做,房产网名字叫啥好听1、设置代理原因因公司安全限制#xff0c;所有外网需配置代理后才可上网#xff0c;但是因为宿主机上设置过代理#xff0c;并未太过多注意此问题#xff0c;之后run时报如下错误#xff1a;# docker run hello-worldUnable to find image hello-world:latest locallydoc…1、设置代理原因因公司安全限制所有外网需配置代理后才可上网但是因为宿主机上设置过代理并未太过多注意此问题之后run时报如下错误# docker run hello-worldUnable to find image hello-world:latest locallydocker: Error response from daemon: Get https://registry-1.docker.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers).See docker run --help.在网上搜索过一番之后发现如果在docker 宿主机上设置了代理(HTTP、HTTPS)之后在docker daemon 启动的时候也要相应的告知 daemon使用代理来访问internet!!2、解决方案尽管docker daemon 的配置可以两种方式来实现2.1通过daemon.json文件来修改2.2通过覆盖docker.service来实现但是对于代理的配置目前为止(docker 17.06)我们只能使用第二个方案。 具体的步骤如下创建docker.service目录mkdir -p /etc/systemd/system/docker.service.d创建HTTPHTTPS代理文件# cat /etc/systemd/system/docker.service.d/http-proxy.conf[Service]EnvironmentHTTP_PROXYxxx.xxx.xxx.xxx:8080 NO_PROXYlocalhost,127.0.0.1[rootlocalhost ~]# cat /etc/systemd/system/docker.service.d/https-proxy.conf[Service]EnvironmentHTTPS_PROXYxxx.xxx.xxx.xxx:8080 NO_PROXYlocalhost,127.0.0.1解析主要是两点内容① HTTPS_PROXY将它的值对应到您所希望设置的代理服务地址和端口(例如: HTTPS_PROXYhttps://proxy.example.com:443)我这里为了保护隐私就用xxx代替.② NO_PROXY 意味着某些情况下我们不需要使用HTTPS代理来访问一般这就配置私有仓库的路径(例如NO_PROXYlocalhost,127.0.0.1,mydocker-registry.com:5000)3、完成修改后保存/刷新# systemctl daemon-reload# systemctl restart docker4、查看修改结果# docker run hello-worldUnable to find image hello-world:latestlocallylatest: Pullingfrom library/hello-worldd1725b59e92d: Pull completeDigest: sha256:0add3ace90ecb4adbf7777e9aacf18357296e799f81cabc9fde470971e499788Status: Downloaded newer imagefor hello-world:latestHellofrom Docker!This message shows that your installation appears to be working correctly.To generatethismessage, Docker took the following steps:1. The Docker client contacted the Docker daemon.2. The Docker daemon pulled the hello-world image fromthe Docker Hub.(amd64)3. The Docker daemon created a new container fromthat image which runs theexecutable that produces the output you are currently reading.4. The Docker daemon streamed that output to the Docker client, which sent itto your terminal.Totrysomething more ambitious, you can run an Ubuntu container with:$ docker run-it ubuntu bashShare images, automate workflows, and more with a free Docker ID:https://hub.docker.com/For more examples and ideas, visit:https://docs.docker.com/get-started/5、重新登录docker hubdocker login -u xxx -p xxxlogin Suceeded可以看到已经成功解决问题参考自官方文档https://docs.docker.com/engine/admin/systemd/