Docker:安装代理来下载图片

我需要设置公司代理,以便Docker可以从公共registry下载图像。

$ sudo docker run hello-world Unable to find image 'hello-world:latest' locally Pulling repository docker.io/library/hello-world Error while pulling image: Get https://index.docker.io/v1/repositories/library/hello-world/images: dial tcp: lookup index.docker.io: no such host 

我正在使用Ubuntu 12.04机器。 我发现这个答案,但systemctl不存在于Ubuntu 12.04。 我怎样才能做到这一点?

谢谢。

尝试运行hello-world容器时出现以下错误

 $docker run hello-world Unable to find image 'hello-world:latest' locally docker: Error response from daemon: Get https://registry-1.docker.io/v2/: dial tcp 34.205.194.204:443: getsockopt: no route to host. 

我尝试了以下链接中的步骤,这些链接对于HTTPS或HTTPconfiguration方面的工作非常有帮助

https://docs.docker.com/engine/admin/systemd/#httphttps-proxy

编辑/etc/defaults/docker.io并添加下列行:

 export http_proxy='http://user:password@proxy-host:proxy-port' 

然后重新启动docker守护进程:

 sudo service docker.io restart 

资源