Docker proxy setting ubuntu 14.04

问题:如果在公司上网的时候,公司设置了proxy,在执行安装完docker后,想run一下hello world,则会出现

odl@ubuntu:~$ docker run hello-world
Unable to find image 'hello-world:latest' locally
Pulling repository docker.io/library/hello-world
docker: Network timed out while trying to connect to https://index.docker.io/v1/repositories/library/hello-world/images. You may want to check your internet connection or if you are behind a proxy..

解决方法:

以下是对于Ubuntu 系统,而对于Centos 是 /etc/sysconfig/docker
sudo vi /etc/default/docker
add this two line to this file:
export http_proxy="http://proxy.esl.example.com:80/"
export https_proxy="https://proxy.esl.example.com:80/"

重启docker: sudo service docker restart
结果:

odl@ubuntu:~$ docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
c04b14da8d14: Pull complete 
Digest: sha256:0256e8a36e2070f7bf2d0b0763dbabdd67798512411de4cdcf9431a1feb60fd9
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

猜你喜欢

转载自blog.csdn.net/u011563903/article/details/52161648