Closed anandadalton closed 5 years ago
E: gnupg, gnupg2 and gnupg1 do not seem to be installed, but one of them is required for this operation
This is your money shot -- this is telling you that apt-key
requires GnuPG installed, but it isn't by default anymore (APT and debootstrap
use just the simpler gpgv
by default for verification instead):
$ docker run -it --rm debian:buster-slim
root@fad5b5d46201:/# apt-key list
E: gnupg, gnupg2 and gnupg1 do not seem to be installed, but one of them is required for this operation
root@fad5b5d46201:/# apt-get update -qq
root@fad5b5d46201:/# apt-get install -yqq gnupg
...
root@fad5b5d46201:/# apt-key list
/etc/apt/trusted.gpg.d/debian-archive-buster-automatic.gpg
----------------------------------------------------------
pub rsa4096 2019-04-14 [SC] [expires: 2027-04-12]
80D1 5823 B7FD 1561 F9F7 BCDD DC30 D7C2 3CBB ABEE
uid [ unknown] Debian Archive Automatic Signing Key (10/buster) <ftpmaster@debian.org>
sub rsa4096 2019-04-14 [S] [expires: 2027-04-12]
/etc/apt/trusted.gpg.d/debian-archive-buster-security-automatic.gpg
-------------------------------------------------------------------
pub rsa4096 2019-04-14 [SC] [expires: 2027-04-12]
5E61 B217 265D A980 7A23 C5FF 4DFA B270 CAA9 6DFA
uid [ unknown] Debian Security Archive Automatic Signing Key (10/buster) <ftpmaster@debian.org>
sub rsa4096 2019-04-14 [S] [expires: 2027-04-12]
/etc/apt/trusted.gpg.d/debian-archive-buster-stable.gpg
-------------------------------------------------------
pub rsa4096 2019-02-05 [SC] [expires: 2027-02-03]
6D33 866E DD8F FA41 C014 3AED DCC9 EFBF 77E1 1517
uid [ unknown] Debian Stable Release Key (10/buster) <debian-release@lists.debian.org>
/etc/apt/trusted.gpg.d/debian-archive-jessie-automatic.gpg
----------------------------------------------------------
pub rsa4096 2014-11-21 [SC] [expires: 2022-11-19]
126C 0D24 BD8A 2942 CC7D F8AC 7638 D044 2B90 D010
uid [ unknown] Debian Archive Automatic Signing Key (8/jessie) <ftpmaster@debian.org>
/etc/apt/trusted.gpg.d/debian-archive-jessie-security-automatic.gpg
-------------------------------------------------------------------
pub rsa4096 2014-11-21 [SC] [expires: 2022-11-19]
D211 6914 1CEC D440 F2EB 8DDA 9D6D 8F6B C857 C906
uid [ unknown] Debian Security Archive Automatic Signing Key (8/jessie) <ftpmaster@debian.org>
/etc/apt/trusted.gpg.d/debian-archive-jessie-stable.gpg
-------------------------------------------------------
pub rsa4096 2013-08-17 [SC] [expires: 2021-08-15]
75DD C3C4 A499 F1A1 8CB5 F3C8 CBF8 D6FD 518E 17E1
uid [ unknown] Jessie Stable Release Key <debian-release@lists.debian.org>
/etc/apt/trusted.gpg.d/debian-archive-stretch-automatic.gpg
-----------------------------------------------------------
pub rsa4096 2017-05-22 [SC] [expires: 2025-05-20]
E1CF 20DD FFE4 B89E 8026 58F1 E0B1 1894 F66A EC98
uid [ unknown] Debian Archive Automatic Signing Key (9/stretch) <ftpmaster@debian.org>
sub rsa4096 2017-05-22 [S] [expires: 2025-05-20]
/etc/apt/trusted.gpg.d/debian-archive-stretch-security-automatic.gpg
--------------------------------------------------------------------
pub rsa4096 2017-05-22 [SC] [expires: 2025-05-20]
6ED6 F5CB 5FA6 FB2F 460A E88E EDA0 D238 8AE2 2BA9
uid [ unknown] Debian Security Archive Automatic Signing Key (9/stretch) <ftpmaster@debian.org>
sub rsa4096 2017-05-22 [S] [expires: 2025-05-20]
/etc/apt/trusted.gpg.d/debian-archive-stretch-stable.gpg
--------------------------------------------------------
pub rsa4096 2017-05-20 [SC] [expires: 2025-05-18]
067E 3C45 6BAE 240A CEE8 8F6F EF0F 382A 1A7B 6500
uid [ unknown] Debian Stable Release Key (9/stretch) <debian-release@lists.debian.org>
root@fad5b5d46201:/#
Thanks for the workaround! I'm wondering if the Debian (and the Ubuntu) images could be rebuilt to avoid this issue? I'm not sure I want to write infrastructure that has the line "RUN... apt update -qq" in it, from a security standpoint.
No, GnuPG was removed from the essential set of both distributions on purpose -- if you want to use apt-key
to manage keys, you'll need to install GnuPG yourself (-qq
was used only for illustrative purposes -- I wouldn't put that in a real Dockerfile
personally). So what I've provided isn't a "workaround" but rather "expected behavior" for these images.
What I'd recommend instead of apt-key
is getting familiar with /etc/apt/trusted.gpg.d
directly (which I find more reliable than using apt-key
anyhow).
For further assistance/discussion, I'd recommend trying the Docker Community Forums, the Docker Community Slack, or Stack Overflow.
Thanks Tianon, I'll do that--sorry for the misunderstanding, and thank you for your clarification.
FYI to anyone who finds this bug later...
The nature of this bug has surprisingly little to do with the contents of /etc/apt/trusted.gpg.d/, which I verified to be the same, more or less, as on my host system. It has something to do with the fact that apt-key is no longer executed as root, but instead as another user, _apt, which has been introduced for this purpose. I can see this user by running "cat /etc/passwd". The relevance of this is that /usr/bin/qemu-arm-static does not have sufficient permissions when copied in. Running "chmod 0777 /usr/bin/qemu-arm-static" resolved the issue for me. Credit to this fix goes to: https://github.com/drtyhlpr/rpi23-gen-image/pull/85
Thanks again
Repro steps:
Using vanilla docker (works)
Using cloud-build-local (google cloud thing) (fails)
Using cloud-build-local (for alpine) (works??)
(incidentally, running the Debian on the actual google cloud build site has a similar problem and outputs the same error messages concerning inability to execute /usr/bin/apt-key.)
Debian cloud-build-local, but instead run /usr/bin/apt-key