Unable to connect to docker hub from China

被刻印的时光 ゝ 提交于 2019-12-23 15:44:38

问题


I'm getting the same thing every time trying to run busybox either with docker on fedora 20 or running boot2docker in VirtualBox:

[me@localhost ~]$ docker run -it busybox Unable to find image 'busybox:latest' locally Pulling repository busybox FATA[0105] Get https://index.docker.io/v1/repositories/library/busybox/images: read tcp 162.242.195.84:443: i/o timeout

I can open https://index.docker.io/v1/repositories/library/busybox/images in a browser and sometimes without using a vpn tunnel so tried to set a proxy in the network settings to the proxy provided by Astrill when using VPN sharing but it will always time out.

Currently in China where there basically is no Internet due to the firewall, npm, git and wget seem to use the Astrill proxy in the terminal (when setting it in network setting of Fedora 20) but somehow I either can't get the docker daemon to use it or something else is wrong.


回答1:


It seems the answer was not so complicated according to the following documentation (had read it before but thought setting proxy in network settings ui would take care of it)

So added the following to /etc/systemd/system/docker.service.d/http-proxy.conf (after creating the docker.service.d directory and conf file):

[Service]
Environment="HTTP_PROXY=http://localhost:3213/"
Environment="HTTPS_PROXY=http://localhost:3213/"

In the Astrill app (I'm sure other provider application provide something similar) there is an option for vpn sharing which will create a proxy; it can be found under settings => vpn sharing.

For git, npm and wget setting the proxy in the ui (gnome-control-center => Network => network proxy) is enough but when doing a sudo it's better to do a sudo su, set the env and then run the command needing a proxy, for example:

sudo su
export http_proxy=http://localhost:3213/
export ftp_proxy=http://localhost:3213/
export all_proxy=socks://localhost:3213/
export https_proxy=http://localhost:3213/
export no_proxy=localhost,127.0.0.0/8,::1
export NO_PROXY="/var/run/docker.sock"
npm install -g ...


来源:https://stackoverflow.com/questions/30434897/unable-to-connect-to-docker-hub-from-china

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