question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Setup script fails while installing Docker: "because the public key is not available: NO_PUBKEY ..."

See original GitHub issue

The installation fails on some systems. Oddly enough, it doesn’t fail on DigitalOcean or GCP.

This is what the failure looks like:

$ sudo bash -c "$(wget -qO- https://raw.githubusercontent.com/Jigsaw-Code/outline-server/master/src/server_manager/install_scripts/install_server.sh)"
> Verifying that Docker is installed .......... NOT INSTALLED
> Would you like to install Docker? This will run 'curl https://get.docker.com/ | sh'. [Y/n] 
> Installing Docker ........................... Docker installation failed, please visit https://docs.docker.com/install for instructions.

Last error: # Executing docker install script, commit: 93d2499759296ac1f9c510605fef85052a2c32be
+ sh -c apt-get update -qq >/dev/null
+ sh -c DEBIAN_FRONTEND=noninteractive apt-get install -y -qq apt-transport-https ca-certificates curl >/dev/null
+ sh -c curl -fsSL "https://download.docker.com/linux/ubuntu/gpg" | gpg --dearmor --yes -o /usr/share/keyrings/docker-archive-keyring.gpg
gpg: WARNING: unsafe ownership on homedir '/home/fortuna/.gnupg'
+ sh -c echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu bionic stable" > /etc/apt/sources.list.d/docker.list
+ sh -c apt-get update -qq >/dev/null
W: GPG error: https://download.docker.com/linux/ubuntu bionic InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 7EA0A9C3F273FCD8
E: The repository 'https://download.docker.com/linux/ubuntu bionic InRelease' is not signed.

Sorry! Something went wrong. If you can't figure this out, please copy and paste all this output into the Outline Manager screen, and send it to us, to see if we can help you.
Full log: /tmp/outline_logqBP

The file /usr/share/keyrings/docker-archive-keyring.gpg is created. However it seems apt-get can’t read the key, resulting in failure, even though it’s running as root (why??).

$ ls -l /usr/share/keyrings/docker-archive-keyring.gpg
-rw-rw---- 1 root root 2760 Jan  6 17:45 /usr/share/keyrings/docker-archive-keyring.gpg

$ sudo apt-get update -qq
W: GPG error: https://download.docker.com/linux/ubuntu bionic InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 7EA0A9C3F273FCD8
E: The repository 'https://download.docker.com/linux/ubuntu bionic InRelease' is not signed.

Changing the permission to a+r fixes the problem:

$ sudo chmod a+r /usr/share/keyrings/docker-archive-keyring.gpg

$ ls -l /usr/share/keyrings/docker-archive-keyring.gpg
-rw-rw-r-- 1 root root 2760 Jan  6 17:45 /usr/share/keyrings/docker-archive-keyring.gpg

$ sudo apt-get update -qq

$ (no errors)

Original complaint on Reddit: https://www.reddit.com/r/outlinevpn/comments/oxn9hx/cannot_install_outline_server_to_ubuntu_20042_lts/

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:6
  • Comments:13 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
fortunacommented, Oct 7, 2021

I hear it may be an issue with the default umask, and that this can also fix the problem:

sudo chmod a+r /usr/share/keyrings/docker-archive-keyring.gpg

From https://stackoverflow.com/questions/60137344/docker-how-to-solve-the-public-key-error-in-ubuntu-while-installing-docker/68764068#68764068

/cc @bemasc

3reactions
warengonzagacommented, Sep 1, 2021

It doesn’t work on Ubuntu 20.04 with aws lightsail or ec2.

I also work with Ubuntu 20.04 and Lightsail instance. You can try do this with new clean Lightsail instance

I solved it by doing sudo apt-get install docker.io and it works like a charm.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Docker: How to solve the public key error in ubuntu while ...
Install Docker Engine on Ubuntu - Official Docker Documentation ... couldn't be verified because the public key is not available: NO_PUBKEY ...
Read more >
Can't install docker on my ubuntu, because of a "NO_PUBKEY ...
The gpg file is there, it has proper perms, even tried in /etc/apt/keyrings . sudo apt update still errors out that there is...
Read more >
Docker installation NO_PUBKEY error on ubuntu focal
If you try to complete official docker installation manual and get this ... be verified because the public key is not available: NO_PUBKEY...
Read more >
Fix Docker installation NO_PUBKEY error on Ubuntu 20.04 LTS
Today we are going to Fix Docker installation NO_PUBKEY error on Ubuntu ... be verified because the public key is not available: NO_PUBKEY...
Read more >
GPG error, Error in discourse-setup command - installation
./discourse-setup Failed to find docker or docker.io on your PATH. ... be verified because the public key is not available: NO_PUBKEY ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found