我在Ubuntu 13.10(Saucy Salamander)上安装了Docker,并在控制台中键入了以下命令:
sudo docker pull busybox
我收到以下错误:
Pulling repository busybox 2014/04/16 09:37:07 Get https://index.docker.io/v1/repositories/busybox/images: dial tcp: lookup index.docker.io on 127.0.1.1:53: no answer from server
Docker版本:
$ sudo docker version Client version: 0.10.0 Client API version: 1.10 Go version (client): go1.2.1 Git commit (client): dc9c28f Server version: 0.10.0 Server API version: 1.10 Git commit (server): dc9c28f Go version (server): go1.2.1 Last stable version: 0.10.0
我在没有身份验证的代理服务器后面,这是我的/etc/apt/apt.conf文件:
/etc/apt/apt.conf
Acquire::http::proxy "http://192.168.1.1:3128/"; Acquire::https::proxy "https://192.168.1.1:3128/"; Acquire::ftp::proxy "ftp://192.168.1.1:3128/"; Acquire::socks::proxy "socks://192.168.1.1:3128/";
我究竟做错了什么?
这是代理HTTP的官方Docker文档的链接:https : //docs.docker.com/config/daemon/systemd/#httphttps- proxy
快速概述:
首先,为Docker服务创建一个systemd插入目录:
mkdir /etc/systemd/system/docker.service.d
现在创建一个名为/etc/systemd/system/docker.service.d/http- proxy.conf添加HTTP_PROXY环境变量的文件:
/etc/systemd/system/docker.service.d/http- proxy.conf
HTTP_PROXY
[Service] Environment="HTTP_PROXY=http://proxy.example.com:80/"
如果您需要在不使用代理的情况下联系内部Docker注册表,则可以通过NO_PROXY环境变量指定它们:
NO_PROXY
Environment="HTTP_PROXY=http://proxy.example.com:80/" Environment="NO_PROXY=localhost,127.0.0.0/8,docker-registry.somecorporation.com"
刷新更改:
$ sudo systemctl daemon-reload
验证配置是否已加载:
$ sudo systemctl show --property Environment docker Environment=HTTP_PROXY=http://proxy.example.com:80/
重新启动Docker:
$ sudo systemctl restart docker