问题:如果在公司上网的时候,公司设置了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..
解决方法:
sudo vi /etc/default/docker
add this two line to this file:
export http_proxy="http://proxy.esl.example.com:80/"
https_proxy="https://proxy.esl.example.com:80/"
结果:
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.