我们在Ubuntu16.04上面安装完Docker(http://blog.csdn.net/dylloveyou/article/details/78233280)后,如果我们主机配置了代理,而没有单独给Docker设置代理,则去Docker Hub查询镜像时会报如下错误:
root@docker02:~# docker search ubuntu
Error response from daemon: Get https://index.docker.io/v1/search?q=ubuntu&n=25: dial tcp 34.234.103.99:443: i/o timeout
设置代理方法如下:
创建配置文件/etc/systemd/system/docker.service.d/http-proxy.conf
,添加如下配置:
[Service]
Environment=”HTTP_PROXY=http://ip:port/”
Environment=”HTTPS_PROXY=http://ip:port/”
重启
systemctl daemon-reload
systemctl restart docker
再次执行docker search 就可以了
root@docker02:~# docker search ubuntu
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
ubuntu Ubuntu is a Debian-based Linux operating s... 6745 [OK]
dorowu/ubuntu-desktop-lxde-vnc Ubuntu with openssh-server and NoVNC 141 [OK]
rastasheep/ubuntu-sshd Dockerized SSH service, built on top of of... 113 [OK]
ansible/ubuntu14.04-ansible Ubuntu 14.04 LTS with ansible 88 [OK]
ubuntu-upstart Upstart is an event-based replacement for ... 80 [OK]
neurodebian NeuroDebian provides neuroscience research... 40 [OK]
ubuntu-debootstrap debootstrap --variant=minbase --components... 31 [OK]
nuagebec/ubuntu Simple always updated Ubuntu docker images... 22 [OK]
tutum/ubuntu Simple Ubuntu docker images with SSH access 19
1and1internet/ubuntu-16-nginx-php-phpmyadmin-mysql-5 ubuntu-16-nginx-php-phpmyadmin-mysql-5 16 [OK]
需要注意,ubuntu16.04的Docker代理设置方式和ubuntu14.04不一样,ubuntu14.04请参考http://blog.csdn.net/dylloveyou/article/details/53582596