Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Could not resolve host: download.docker.com" while installing docker CE

I am getting this error while installing docker CE on my ubuntu machine

curl: (6) Could not resolve host: download.docker.com
gpg: no valid OpenPGP data found.

While performing the step

Add Docker’s official GPG key:
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

as mentioned here https://docs.docker.com/engine/installation/linux/docker-ce/ubuntu/#install-docker-ce-1

like image 963
Kuldeep Dangi Avatar asked Jan 02 '18 06:01

Kuldeep Dangi


5 Answers

  1. Adding -4 helped to resolve the issue, however, I got another error:

curl -4fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

gpg: can't connect to the agent: IPC connect call failedbuntu1.1)

  1. Then I followed this answer: How to connect to the agent: IPC connect call

and it worked:

curl -4fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

OK

However, I got W: Failed to fetch https://download.docker.com/linux/ubuntu/dists/focal/InRelease Temporary failure resolving 'download.docker.com' error from sudo apt-get update

  1. The last issue got resolved by running:

echo "nameserver 8.8.8.8" | sudo tee /etc/resolv.conf > /dev/null

like image 145
Kondor Avatar answered Sep 16 '22 11:09

Kondor


If the problem persists, then change/add your DNS server to google DNS servers : 8.8.8.8,8.8.4.4

You can try the below commands before changing your DNS server :

dig @8.8.8.8 download.docker.com

dig @8.8.4.4 download.docker.com

If you are on ubuntu, then try the below link to change the DNS server : https://askubuntu.com/a/820873/707990

like image 25
sudip Avatar answered Oct 25 '22 13:10

sudip


By forcing curl and apt to use ipv4, download.docker.com is resolved correctly. in curl, add the -4 argument

 Add Docker’s official GPG key:
$ curl -4fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

then to force apt to use ipv4 => https://www.vultr.com/docs/force-apt-get-to-ipv4-or-ipv6-on-ubuntu-or-debian

like image 23
Laurent Caille Avatar answered Oct 25 '22 13:10

Laurent Caille


It's just a random error (may happens due to instable Internet, DNS caching ...)

In my case just opening "https://download.docker.com/" in my browser (to make sure Internet is working and the docker website is up) resolved the problem

like image 8
youssef Avatar answered Oct 25 '22 13:10

youssef


In my case disconnecting from VPN solved the problem.

like image 1
Kamil Pajak Avatar answered Oct 25 '22 12:10

Kamil Pajak