Docker镜像由于代理问题导致不能下载的解决办法

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/i042416/article/details/88073145

我用的系统:Ubuntu

使用如下命令拉名为busybox的Docker镜像:

sudo docker pull busybox
image

得到下列错误消息:

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版本:

我使用的proxy:

$ 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
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/”;

解决方案

新建一个目录:

mkdir /etc/systemd/system/docker.service.d

创建一个文件:

/etc/systemd/system/docker.service.d/http-proxy.conf

添加环境变量:

HTTP_PROXY environment variable:

[Service]
Environment=“HTTP_PROXY=http://proxy.example.com:80/”

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

猜你喜欢

转载自blog.csdn.net/i042416/article/details/88073145