15

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

Kuldeep Dangi
  • 4,126
  • 5
  • 33
  • 56

8 Answers8

26

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

Daniele Santi
  • 771
  • 3
  • 24
  • 31
Laurent Caille
  • 261
  • 3
  • 2
  • 1
    While providing links is useful, it would be MORE helpful to the asker if you posted a summary of the steps involved on the link you posted. Can you please elaborate on the part that says "to force apt to use ipv4"? Links can go dead any time. For more tips, see [How to answer](https://stackoverflow.com/questions/how-to-answer). – Daniele Santi Jan 23 '19 at 10:05
9

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

youssef
  • 493
  • 3
  • 11
4

In my case disconnecting from VPN solved the problem.

Kamil Pajak
  • 340
  • 2
  • 13
3

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

sudip
  • 2,781
  • 1
  • 29
  • 41
1
  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

Kondor
  • 11
  • 3
1

Manually Add GPG Key

If that does not work then click on the link to download gpg key and then manually add it

sudo apt-key add '/home/user/Downloads/gpg' 
Hitesh Sahu
  • 41,955
  • 17
  • 205
  • 154
0

You need to set proxy in ubuntu. It workd for me.

export https_proxy=<YOUR_PROXY_ADDRESS:PORT>
nkirit
  • 379
  • 2
  • 4
  • 13
0

This error occurred when system is not able to connect to internet properly. If you are doing it in virtual machine then change the network type from NAT to bridged. After changing it check internet connection is working properly you can check docker download page. Hope it helps.