'Building from Dockerfile and getting "The following signatures couldn't be verified because the public key is not available: NO_PUBKEY"
I'm trying to build a PHP 5.3/Apache for local use using a Dockerfile that starts:
FROM php:5.3-apache
RUN apt-get update && \
apt-get install -y \
libfreetype6-dev \
libjpeg62-turbo-dev \
libmcrypt-dev \
libpng-dev
But when "Reading package lists" I get:
W: GPG error: http://security.debian.org jessie/updates InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 9D6D8F6BC857C906 NO_PUBKEY AA8E81B4331F7F50
W: GPG error: http://http.debian.net jessie-updates InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 7638D0442B90D010
W: GPG error: http://http.debian.net jessie Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 7638D0442B90D010
After reading this page I tried adding this after the first line:
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys AA8E81B4331F7F50 && \
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 7638D0442B90D010
But get this error:
W: There is no public key available for the following key IDs:
9D6D8F6BC857C906
W: Failed to fetch http://http.debian.net/debian/dists/jessie/Release.gpg Connection failed [IP: 130.89.148.77 80]
Knowing next to nothing about Ubuntu vs Debian I tried the same but with keyring.debian.org
in place of keyserver.ubuntu.com
and got:
gpgkeys: key AA8E81B4331F7F50 can't be retrieved
gpg: no valid OpenPGP data found.
gpg: Total number processed: 0
From another question I tried this:
RUN apt-get update && \
apt-get install -y --no-install-recommends \
apt-transport-https \
ca-certificates
RUN apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys AA8E81B4331F7F50
RUN apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 7638D0442B90D010
But get the same GPG Error as originally.
I'm now stumped as to how to proceed. (I know PHP 5.3 is very out of date but I can't change that unfortunately.)
Solution 1:[1]
From http://forums.debian.net/viewtopic.php?f=10&t=141778, one solution is.
gpg --recv-keys AA8E81B4331F7F50
gpg --export AA8E81B4331F7F50| apt-key add -
The Dockerfile could look like this:
FROM php:5.3-apache
RUN for key in AA8E81B4331F7F50 7638D0442B90D010 9D6D8F6BC857C906; do \
gpg --recv-keys "$key" \
&& gpg --export "$key" | apt-key add - ; \
done
RUN apt-get update && \
apt-get install -y \
libfreetype6-dev \
libjpeg62-turbo-dev \
libmcrypt-dev \
libpng-dev
Solution 2:[2]
After several more attempts and errors I found that just doing this, without the preceding install of apt-transport-https ca-certificates
seems to do the job:
RUN apt-key adv --keyserver hkp://pool.sks-keyservers.net:80 --recv-keys AA8E81B4331F7F50 && \
apt-key adv --keyserver hkp://pool.sks-keyservers.net:80 --recv-keys 7638D0442B90D010
I do get this error but it doesn't appear to affect anything, and installation continues afterwards:
W: There is no public key available for the following key IDs:
9D6D8F6BC857C906
Solution 3:[3]
If you are on Debian
/Debian(Container)
, to fix your problem:
W: There is no public key available for the following key IDs:
9D6D8F6BC857C906
Just try the below code:
sudo apt-get install debian-keyring debian-archive-keyring
sudo apt-key update
sudo apt-get update
Solution 4:[4]
Having run into the same issues and finding that none of the above solutions worked, I considered the fact that I was calling upon an image that was a slightly older version than current (openjdk:10-sid) and thought that being a dead-end release, there would be no keys to match to for updates.
So, I just commented out:
RUN apt-get update
and let the other apt-get installs happen. The build finally succeeded. I wouldn't do this as a rule, but it seems reasonable for older images.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | |
Solution 2 | Phil Gyford |
Solution 3 | Vittore Marcas |
Solution 4 | Robert Casey |