Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

ubuntu - lookup registry-1.docker.io: no such host

I have docker daemon running on my Ubuntu 16.4 server

my server details:

No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 17.04 Release: 17.04 Codename: zesty

I'm receiving the following error:

aa@aaa-VirtualBox:/etc/default$ docker run hello-world
Unable to find image 'hello-world:latest' locally
docker: Error response from daemon: Get https://registry-1.docker.io/v2/: dial tcp: lookup registry-1.docker.io: no such host.
See 'docker run --help'.

I have set the http_proxy and the https_proxy beacuse i'm behind a corp proxy/firewall

Any clues how I can fix this issue?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You need to set the proxy for Docker daemon also using environment variable. Docker run is also doing docker pull since the image doesn't exists. In your case the proxy is only applied to the docker run command, which delegates to the docker daemon which is running without proxy.

Create a file named /etc/systemd/system/docker.service.d/10_docker_proxy.conf with below content

[Service]
Environment=HTTP_PROXY=http://1.1.1.1:111
Environment=HTTPS_PROXY=http://1.1.1.1:111

Make sure to update the proxy as per the ones you have 1.1.1.1:111 is just an example

Then execute below commands to restart docker

sudo systemctl daemon-reload
sudo systemctl restart docker

Now use your docker run command and it should work


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...