apt cannot verify the Docker repository: public key is not available
The following signatures couldn't be verified because the public key is not available: NO_PUBKEYShort answer
apt checks every repository against a signing key. NO_PUBKEY means the Docker key is missing, unreadable, in a format this apt cannot use, or the Signed-By path in the source file points to nothing. Re-create the keyring and sources file the way Docker's install guide shows, then run apt update.
Fix it fast
1Find out which cause you have
Look at the source file for Docker and check that the key file it names exists.
cat /etc/apt/sources.list.d/docker.sources ls -l /etc/apt/keyrings/2Match what you see, then jump to its fix
- 1
NO_PUBKEY on download.docker.com right after adding the repositoryThe key was never downloaded, or the file is not where Signed-By saysFix - 2
NO_PUBKEY persists although the key file existsThe sources file is incomplete or was written by hand with a typoFix - 3
NO_PUBKEY on an old Ubuntu or Debian although the key file is presentThe key is ASCII-armored and this apt is too old to read itFix
- 1
What does the error look like?
The following signatures couldn't be verified because the public key is not available: NO_PUBKEY
Cause 1 of 3
The key was never downloaded, or the file is not where Signed-By says
1Check
The Signed-By line must point to a real file, not a fingerprint. Compare the path in the source file with the keyring folder.
grep -n "Signed-By" /etc/apt/sources.list.d/docker.sources
ls -l /etc/apt/keyrings/docker.asc2Fix
Download the key to the path the source file uses, as Docker's guide shows, and make it readable.
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc3Verify
apt update runs with no signature error for the Docker repository.
sudo apt updateConfirmed by docs.docker.com
Cause 2 of 3
The sources file is incomplete or was written by hand with a typo
1Check
Compare your file to the documented one: Types, URIs, Suites, Components, Architectures and Signed-By.
cat /etc/apt/sources.list.d/docker.sources2Fix
Rewrite the file with the documented content. The suite is read from the OS release.
sudo tee /etc/apt/sources.list.d/docker.sources <<EOF
Types: deb
URIs: https://download.docker.com/linux/ubuntu
Suites: $(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}")
Components: stable
Architectures: $(dpkg --print-architecture)
Signed-By: /etc/apt/keyrings/docker.asc
EOF
sudo apt update3Verify
apt update lists download.docker.com without errors.
apt-cache policy docker-ceConfirmed by docs.docker.com
Cause 3 of 3
The key is ASCII-armored and this apt is too old to read it
1Check
Debian's guidance: armored key files only work with apt 1.4 or later. Check your apt version.
apt --version2Fix
Convert the key to the binary format with gpg --dearmor, save it as a .gpg file, and point Signed-By at that file.
sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg /etc/apt/keyrings/docker.asc
# then set: Signed-By: /etc/apt/keyrings/docker.gpg3Verify
apt update completes with no signature error.
sudo apt updateConfirmed by wiki.debian.org
How do I stop it coming back?
- Follow the vendor's current install page instead of old copy-pasted apt-key add commands.
- Keep third-party keys in /etc/apt/keyrings and reference them with Signed-By.
- Do not load third-party keys with apt-key add or put them in trusted.gpg.d.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
Related fixes
Servers
Apache logs SIGWINCH and exits on its own
the httpd container stops although nothing crashed
SIGWINCH is Apache's graceful-stop signal.
2 causes, each with a fixServers
sam local fails: Running AWS SAM projects locally requires Docker
Cannot connect to the Docker daemon. Is the docker daemon running on this host?
sam local start-api and sam local invoke run your function inside a Docker container, so SAM stops if it cannot talk to Docker.
3 causes, each with a fixServers
dnf fails to download repo metadata in a CentOS 8 Docker build
The same Dockerfile built fine before 2022
CentOS Linux 8 reached end of life on 31 December 2021 and its content left the mirrors.
2 causes, each with a fixServers
pip install confluent-kafka fails because librdkafka/rdkafka.h is missing
pip stops while building confluent-kafka from source
The error means pip is compiling confluent-kafka from source, and the compiler cannot find the librdkafka C headers.
3 causes, each with a fixServers
Cypress says the npm package is installed but the binary is missing
Cypress binary is missing after npm install in CI or in a Docker build
The npm package is only a launcher.
3 causes, each with a fixServers
A dev container port does not open in the browser when Docker runs on a remote host
If your application only accepts calls from localhost, it will reject connections from published ports
Three things usually break it: the app listens only on localhost inside the container, so published ports are rejected; you open the container port instead of the mapped localhost port VS Code shows; or you changed appPort or a Compose ports list and did not rebuild.
3 causes, each with a fix