Cannot download Docker images behind a proxy

2019-01-01 06:20发布

I installed Docker on my Ubuntu 13.10 (Saucy Salamander) and when I type in my console:

sudo docker pull busybox

I get the following error:

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 version:

$ 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

I am behind a proxy server with no authentication, and this is my /etc/apt/apt.conf file:

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

What am I doing wrong?

标签: proxy docker
22条回答
无与为乐者.
2楼-- · 2019-01-01 06:29

Try this:

sudo HTTP_PROXY=http://<IP address of proxy server:port> docker -d & 
查看更多
千与千寻千般痛.
3楼-- · 2019-01-01 06:30

To configure Docker to work with a proxy you need to add the HTTPS_PROXY / HTTP_PROXY environment variable to the Docker sysconfig file (/etc/sysconfig/docker).

Depending on if you use init.d or the services tool you need to add the "export" statement (due to Debian Bug report logs - #767441. Examples in /etc/default/docker are misleading regarding the supported syntax):

HTTPS_PROXY="https://<user>:<password>@<proxy-host>:<proxy-port>"
HTTP_PROXY="https://<user>:<password>@<proxy-host>:<proxy-port>"
export HTTP_PROXY="https://<user>:<password>@<proxy-host>:<proxy-port>"
export HTTPS_PROXY="https://<user>:<password>@<proxy-host>:<proxy-port>"

The Docker repository (Docker Hub) only supports HTTPS. To get Docker working with SSL intercepting proxies you have to add the proxy root certificate to the systems trust store.

For CentOS, copy the file to /etc/pki/ca-trust/source/anchors/ and update the CA trust store and restart the Docker service.

If your proxy uses NTLMv2 authentication - you need to use intermediate proxies like Cntlm to bridge the authentication. This blog post explains it in detail.

查看更多
忆尘夕之涩
4楼-- · 2019-01-01 06:32

If you're in Ubuntu, execute these commands to add your proxy.

sudo nano /etc/default/docker

And uncomment the lines that specifies

#export http_proxy = http://username:password@10.0.1.150:8050

And replace it with your appropriate proxy server and username.

Then restart Docker using:

service docker restart

Now you can run Docker commands behind proxy:

docker search ubuntu
查看更多
冷夜・残月
5楼-- · 2019-01-01 06:33

If you're using the new Docker for Mac (or Docker for Windows), just right-click the Docker tray icon and select Preferences (Windows: Settings), then go to Advanced, and under Proxies specify your proxy settings there. Click Apply and Restart and wait until Docker restarts.

查看更多
初与友歌
6楼-- · 2019-01-01 06:35

If you are on Ubuntu, you should execute this command:

export https_proxy=http://your_name:password@ip_proxy:port docker 

And reload Docker with:

service docker.io restart

Or go to /etc/docker.io with nano...

查看更多
后来的你喜欢了谁
7楼-- · 2019-01-01 06:35

In my network, Ubuntu works behind a corporate ISA proxy server. And it requires authentication. I tried all the solutions mentioned above and nothing helped. What really helped was to write a proxy line in file /etc/systemd/system/docker.service.d/https-proxy.conf without a domain name.

Instead of

Environment="HTTP_PROXY=http://user@domain:password@proxy:8080"

or

Environment="HTTP_PROXY=http://domain\user:password@proxy:8080"

and some other replacement such as @ -> %40 or \ -> \\ I tried to use

Environment="HTTP_PROXY=http://user:password@proxy:8080"

And it works now.

查看更多
登录 后发表回答