Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to find image error, How to setup proxy to download images

Tags:

docker

I need setup the corporation proxy in order Docker can download the images from public registry.

$ sudo docker run hello-world 
Unable to find image 'hello-world:latest' locally 
Pulling repository docker.io/library/hello-world 
Error while pulling image: Get https://index.docker.io/v1/repositories/library/hello-world/images: dial tcp: lookup index.docker.io: no such host

I'm using Ubuntu 12.04 machine. I have found this answer but systemctl is not present in Ubuntu 12.04. How can I do this?

Thanks.

like image 529
Héctor Avatar asked Jan 18 '16 10:01

Héctor


1 Answers

From Docker official documentation,

Create a systemd drop-in directory for the docker service:

$ sudo mkdir -p /etc/systemd/system/docker.service.d

Create a file called /etc/systemd/system/docker.service.d/http-proxy.conf that adds the HTTP_PROXY environment variable:

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

Or, if you are behind an HTTPS proxy server, create a file called /etc/systemd/system/docker.service.d/https-proxy.conf that adds the HTTPS_PROXY environment variable:

[Service]
Environment="HTTPS_PROXY=https://proxy.example.com:443/"

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

[Service]    
Environment="HTTP_PROXY=http://proxy.example.com:80/" "NO_PROXY=localhost,127.0.0.1,docker-registry.somecorporation.com"

Or, if you are behind an HTTPS proxy server:

[Service]    
Environment="HTTPS_PROXY=https://proxy.example.com:443/" "NO_PROXY=localhost,127.0.0.1,docker-registry.somecorporation.com"

Flush changes:

$ sudo systemctl daemon-reload

Restart Docker:

$ sudo systemctl restart docker

Verify that the configuration has been loaded:

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

Or, if you are behind an HTTPS proxy server:

$ systemctl show --property=Environment docker
Environment=HTTPS_PROXY=https://proxy.example.com:443/
like image 181
Sufiyan Ghori Avatar answered Oct 20 '22 16:10

Sufiyan Ghori