Docker proxy setting ubuntu 14.04

Frank範發表於2016-08-09

問題:如果在公司上網的時候,公司設定了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.

相關文章