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

On Ubuntu 14.04 (Trusty Tahr) with Docker 1.9.1, I just uncommented the http_proxy line, updated the value and then restarted the Docker service.

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

and then

service docker restart
查看更多
倾城一夜雪
3楼-- · 2019-01-01 06:41

To solve the problem with curl in Docker build, I added the following inside the Dockerfile:

ENV http_proxy=http://infoprx2:8080
ENV https_proxy=http://infoprx2:8080
RUN apt-get update && apt-get install -y curl vim

Note that the ENV statement is BEFORE the RUN statement.

And in order to make the Docker daemon able to access the Internet (I use Kitematic with boot2docker), I added the following into /var/lib/boot2docker/profile:

export HTTP_PROXY=http://infoprx2:8080
export HTTPS_PROXY=http://infoprx2:8080

Then I restarted Docker with sudo /etc/init.d/docker restart.

查看更多
妖精总统
4楼-- · 2019-01-01 06:42

On Ubuntu you need to set the http_proxy for the Docker daemon, not the client process. This is done in /etc/default/docker (see here).

查看更多
栀子花@的思念
5楼-- · 2019-01-01 06:47

On RHEL6.6 only this works (note the use of export):

/etc/sysconfig/docker

export http_proxy="http://myproxy.example.com:8080"
export https_proxy="http://myproxy.example.com:8080"

NOTE: Both can use the http protocol.)

Thanks to https://crondev.com/running-docker-behind-proxy/

查看更多
几人难应
6楼-- · 2019-01-01 06:50

On CentOS the configuration file for Docker is at:

/etc/sysconfig/docker

Adding the below line helped me to get the Docker daemon working behind a proxy server:

HTTP_PROXY="http://<proxy_host>:<proxy_port>"
HTTPS_PROXY="http://<proxy_host>:<proxy_port>"
查看更多
浅入江南
7楼-- · 2019-01-01 06:50

Simply setting proxy environment variables did not help me in version 1.0.1... I had to update the /etc/default/docker.io file with the correct value for the "http_proxy" variable.

查看更多
登录 后发表回答