Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot download Docker images behind a proxy

Tags:

docker

proxy

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?

like image 780
rpayanm Avatar asked Apr 16 '14 13:04

rpayanm


People also ask

How do I pull a docker image behind a proxy?

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 ). The Docker repository (Docker Hub) only supports HTTPS.

Does Docker use system proxy?

In Docker 17.07 and higher, you can configure the Docker client to pass proxy information to containers automatically. In Docker 17.06 and earlier versions, you must set the appropriate environment variables within the container.

What is a proxy server docker?

docker-proxify is a docker-within-docker container that eases development when operating behind a restrictive firewall that requires a proxy server for outbound internet connectivity, by making the use of the proxy server transparent to the applications running inside the container.


2 Answers

Here is a link to the official Docker documentation for proxy HTTP: https://docs.docker.com/config/daemon/systemd/#httphttps-proxy

A quick outline:

First, create a systemd drop-in directory for the Docker service:

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

Now create a file called /etc/systemd/system/docker.service.d/http-proxy.conf that adds the HTTP_PROXY and HTTPS_PROXY environment variables:

[Service] Environment="HTTP_PROXY=http://proxy.example.com:80/" Environment="HTTPS_PROXY=http://proxy.example.com:80/" 

If you have internal Docker registries that you need to contact without proxying you can specify them via the NO_PROXY environment variable:

Environment="HTTP_PROXY=http://proxy.example.com:80/" Environment="HTTPS_PROXY=http://proxy.example.com:80/" Environment="NO_PROXY=localhost,127.0.0.0/8,docker-registry.somecorporation.com" 

Flush changes:

$ sudo systemctl daemon-reload 

Verify that the configuration has been loaded:

$ sudo systemctl show --property Environment docker Environment=HTTP_PROXY=http://proxy.example.com:80/ Environment=HTTPS_PROXY=http://proxy.example.com:80/ 

Restart Docker:

$ sudo systemctl restart docker 

Footnote regarding HTTP_PROXY vs. HTTPS_PROXY: for a long time, setting HTTP_PROXY alone has been good enough. But with version 20.10.8, Docker has moved on to Go 1.16, which changes the semantics of this variable: https://golang.org/doc/go1.16#net/http
For https:// URLs, the proxy is now determined by the HTTPS_PROXY variable, with no fallback on HTTP_PROXY.

like image 86
Alexandre Mélard Avatar answered Oct 19 '22 07:10

Alexandre Mélard


Your APT proxy settings are not related to Docker.

Docker uses the HTTP_PROXY environment variable, if present. For example:

sudo HTTP_PROXY=http://192.168.1.1:3128/ docker pull busybox 

But instead, I suggest you have a look at your /etc/default/dockerconfiguration file: you should have a line to uncomment (and maybe adjust) to get your proxy settings applied automatically. Then restart the Docker server:

service docker restart 
like image 37
mbarthelemy Avatar answered Oct 19 '22 05:10

mbarthelemy