Proxy 无法下载代理后的Docker映像

Proxy 无法下载代理后的Docker映像,proxy,docker,Proxy,Docker,我在我的Ubuntu 13.10(俏皮蝾螈)上安装了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 fro

我在我的Ubuntu 13.10(俏皮蝾螈)上安装了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
文件:

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/";

我做错了什么?

您的APT代理设置与Docker无关

Docker使用HTTP_代理环境变量(如果存在)。例如:

sudo HTTP_PROXY=http://192.168.1.1:3128/ docker pull busybox
但是,我建议您查看一下您的
/etc/default/docker
配置文件:您应该有一行可以取消注释(或者调整)以自动应用代理设置。然后重新启动Docker服务器:

service docker restart

安装Docker后,请执行以下操作:

[mdesales@pppdc9prd1vq ~]$ sudo HTTP_PROXY=http://proxy02.ie.xyz.net:80 ./docker -d &
[2] 20880
然后,您可以拉动或执行任何操作:

mdesales@pppdc9prd1vq ~]$ sudo docker pull base
2014/04/11 00:46:02 POST /v1.10/images/create?fromImage=base&tag=
[/var/lib/docker|aa088847] +job pull(base, )
Pulling repository base
b750fe79269d: Download complete
27cf78414709: Download complete
[/var/lib/docker|aa088847] -job pull(base, ) = OK (0)

在CentOS上,Docker的配置文件位于:

/etc/sysconfig/docker

添加以下行帮助我使Docker守护进程在代理服务器后面工作:

HTTP_PROXY="http://<proxy_host>:<proxy_port>"
HTTPS_PROXY="http://<proxy_host>:<proxy_port>"
HTTP\u PROXY=“HTTP://:”
HTTPS_PROXY=“http://:”

在Ubuntu上,您需要为Docker守护进程而不是客户端进程设置http\U代理。这是在
/etc/default/docker
中完成的(请参阅)。

为了扩展,为了在CentOS 7中工作,我必须删除“导出”命令。所以编辑

/etc/sysconfig/docker
并加上:

HTTP_PROXY="http://<proxy_host>:<proxy_port>"
HTTPS_PROXY="https://<proxy_host>:<proxy_port>"
http_proxy="${HTTP_PROXY}"
https_proxy="${HTTPS_PROXY}"

.

要将Docker配置为使用代理,需要将HTTPS\u proxy/HTTP\u proxy环境变量添加到Docker sysconfig文件(
/etc/sysconfig/Docker

根据您是使用
init.d
还是使用服务工具添加“export”语句(由于以下原因):

HTTPS\u PROXY=“HTTPS://:@:”
HTTP_PROXY=“https:/:@:”
导出HTTP_PROXY=“https://:@:”
导出HTTPS_PROXY=“HTTPS:/:@:”
Docker存储库(Docker Hub)仅支持HTTPS。要让Docker使用SSL拦截代理,必须将代理根证书添加到系统信任存储中

对于CentOS,将文件复制到
/etc/pki/ca-trust/source/archors/
,更新ca-trust存储并重新启动Docker服务


如果您的代理使用NTLMv2身份验证,则需要使用中间代理,如桥接身份验证

以下是代理HTTP的Docker官方文档链接:

简要概述:

首先,为Docker服务创建一个systemd drop-in目录:

mkdir /etc/systemd/system/docker.service.d
现在创建一个名为
/etc/systemd/system/docker.service.d/http proxy.conf
的文件,该文件添加了
http\u proxy
环境变量:

[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"
如果您有内部Docker注册表,需要在不代理的情况下进行联系,则可以通过
NO\u PROXY
环境变量指定它们:

[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 service docker restart
$ sudo systemctl restart docker

如果您在Ubuntu上,则应执行以下命令:

export https_proxy=http://your_name:password@ip_proxy:port docker 
并使用以下命令重新加载Docker:

service docker.io restart

或者使用nano…

进入
/etc/docker.io
,因为我还不能发表评论:

对于CentOS 7,我需要激活“docker.service”中的环境文件,如下所述:

编辑:我正在添加Nilesh所述的解决方案。我需要打开“/etc/systemd/system/docker.service”,并且必须在该部分中添加

[服务]

环境文件=-/etc/sysconfig/docker

Environment=http_proxy="http://ip:port"
Environment=https_proxy="http://ip:port"
Environment=no_proxy="hostname"

直到那时,文件“etc/sysconfig/docker”才加载到我的系统上。

在1.0.1版中,简单地设置代理环境变量对我没有帮助。。。我必须用“http_proxy”变量的正确值更新
/etc/default/docker.io
文件。

在docker的新版本docker engine中,在基于systemd的发行版中,您应该将环境变量行添加到/lib/systemd/system/docker.service,正如其他人提到的:

Environment="HTTP_PROXY=http://hostname_or_ip:port/"
试试这个:

sudo HTTP_PROXY=http://<IP address of proxy server:port> docker -d & 
sudo HTTP_PROXY=HTTP://docker-d& 在Ubuntu14.04(Trusty Tahr)和Docker 1.9.1上,我刚刚取消了http_proxy的注释,更新了值,然后重新启动了Docker服务

export http_proxy="http://proxy.server.com:80"
然后

service docker restart

这是对我有效的修复:Ubuntu,Docker版本:1.6.2

在文件
/etc/default/docker
中,添加以下行:

export http_proxy='http://<host>:<port>'

如果您正在使用新的适用于Mac的Docker(或适用于Windows的Docker),只需右键单击Docker托盘图标并选择“首选项”(Windows:Settings),然后转到“高级”,并在“代理”下指定您的代理设置。单击应用并重新启动,等待Docker重新启动。

为了解决Docker build中的curl问题,我在Docker文件中添加了以下内容:

ENV http_proxy=http://infoprx2:8080
ENV https_proxy=http://infoprx2:8080
RUN apt-get update && apt-get install -y curl vim
请注意,ENV语句位于RUN语句之前

为了使Docker守护进程能够访问Internet(我使用Kitematic和boot2docker),我在
/var/lib/boot2docker/profile
中添加了以下内容:

export HTTP_PROXY=http://infoprx2:8080
export HTTPS_PROXY=http://infoprx2:8080
然后我用
sudo/etc/init.d/Docker restart

重新启动了Docker,为什么本地绑定的代理无法工作 问题 如果您正在运行本地绑定的代理,例如侦听
127.0.0.1:8989
,则它在Mac的Docker中不起作用。从:

我想从容器连接到主机上的服务 Mac有一个不断变化的IP地址(如果您没有网络访问权限,则没有)。我们目前的建议是在Mac上的
lo0
接口上附加一个未使用的IP;例如:
sudo ifconfig lo0 alias 10.200.10.1/24
,并确保您的服务正在侦听此地址或
0.0.0
(即不是
127.0.0.1
)。然后容器可以连接到此地址

Docker服务器端也是如此。(要了解Docker的服务器端和客户端,请尝试运行
Docker版本
),服务器端运行在具有自己的
localhost
的虚拟化层上。因此,它不会连接到主机操作系统的
localhost
上的代理服务器

那个
$ docker rmi -f hello-world
  ...

$ 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
  ...
# Set up socks5 proxy server
ssh sshUser@proxyServer -C -N -g -D \
     proxyServerIp:9999 \
     -o ExitOnForwardFailure=yes \
     -o ServerAliveInterval=60

# Configure dockerd and restart.
# NOTICE: using "all_proxy"
mkdir -p /etc/systemd/system/docker.service.d
cat > /etc/systemd/system/docker.service.d/http-proxy.conf <<EOF
[Service]
Environment="all_proxy=socks5://proxyServerIp:9999"
Environment="NO_PROXY=localhost,127.0.0.1,private.docker.registry.com"
EOF

systemctl daemon-reload
systemctl restart docker

# Test whether can pull images
docker run -it --rm alpine:3.5
export http_proxy="http://myproxy.example.com:8080"
export https_proxy="http://myproxy.example.com:8080"
[Service]
Environment="ftp_proxy=http://<user>:<password>@<proxy_ip>:<proxy_port>/"
Environment="http_proxy=http://<user>:<password>@<proxy_ip>:<proxy_port>/"
Environment="https_proxy=http://<user>:<password>@<proxy_ip>:<proxy_port>/"
sudo nano /etc/default/docker
#export http_proxy = http://username:password@10.0.1.150:8050
service docker restart
docker search ubuntu
Environment="HTTP_PROXY=http://user@domain:password@proxy:8080"
Environment="HTTP_PROXY=http://domain\user:password@proxy:8080"
Environment="HTTP_PROXY=http://user:password@proxy:8080"
$ sudo vim /etc/systemd/system/docker.service.d/http_proxy.conf
[Service]
Environment="HTTP_PROXY=http://username:password@IP:port/"
$ sudo systemctl daemon-reload
$ sudo systemctl restart docker
$ docker pull hello-world
Using default tag: latest
latest: Pulling from library/hello-world
1b930d010525: Pull complete
Digest: sha256:2557*********************************8
Status: Downloaded newer image for hello-world:latest
< user>:< password>@< proxy-host>:< proxy-port>
< user>:< password>@< proxy-host>:< proxy-port>
"geronimous:mypassword@192.168.44.55:8080"
docker save <image-name> --output <archive-name>.tar
docker load <archive-name>.tar
[Service]

Environment="HTTP_PROXY=http://proxy.server.com:80"

Environment="HTTPS_PROXY=http://proxy.server.com:80"

Environment="NO_PROXY=.proxy.server.com,*.proxy.server.com,localhost,127.0.0.1,::1"
http_proxy=http://proxy.server.com:80
https_proxy=http://proxy.server.com:80
ftp_proxy=http://proxy.server.com:80
no_proxy=127.0.0.1,10.0.0.0/8,3.0.0.0/8,localhost,*.abc.com
Environment=http_proxy="http://ip:port"
Environment=https_proxy="http://ip:port"
Environment=no_proxy="hostname"
ENV http_proxy http://ip:port
ENV https_proxy http://ip:port
ENV no_proxy "hostname"