yum error – Public key for *.rpm is not installed

工作中使用docker基于centos8镜像安装编译环境,遇到

yum error – Public key for *.rpm is not installed,

....

You can remove cached packages by executing 'dnf clean packages'.
Error: GPG check FAILED

的报错,

涉及到报错的Dockerfile 命令行:

FROM centos:8

RUN yum install -y \
    openssl-devel \
    bc \
    cmake \
    elfutils-libelf-devel
RUN dnf -y --enablerepo=PowerTools  install boost-static
RUN yum -y groupinstall 'Development Tools'

报错信息:

# docker build -t centos8_kernel:test -f Dockerfile_centos_kernel_8  .
Sending build context to Docker daemon  17.41kB
.
.
.
(41/41): libicu-devel-60.2-7.el8.x86_64.rpm      31 kB/s | 922 kB     00:30
--------------------------------------------------------------------------------
Total                                           1.7 MB/s |  65 MB     00:37
warning: /var/cache/dnf/AppStream-02e86d1c976ab532/packages/boost-1.66.0-6.el8.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID 8483c65d: NOKEY
CentOS-8 - AppStream                            1.6 MB/s | 1.6 kB     00:00
Importing GPG key 0x8483C65D:
 Userid     : "CentOS (CentOS Official Signing Key) <[email protected]>"
 Fingerprint: 99DB 70FA E1D7 CE22 7FB6 4882 05B5 55B3 8483 C65D
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
Key imported successfully
Import of key(s) didn't help, wrong key(s)?
CentOS-8 - Base                                 1.6 MB/s | 1.6 kB     00:00
Importing GPG key 0x8483C65D:
 Userid     : "CentOS (CentOS Official Signing Key) <[email protected]>"
 Fingerprint: 99DB 70FA E1D7 CE22 7FB6 4882 05B5 55B3 8483 C65D
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
Key imported successfully
Import of key(s) didn't help, wrong key(s)?
CentOS-8 - PowerTools                           1.6 MB/s | 1.6 kB     00:00
Importing GPG key 0x8483C65D:
 Userid     : "CentOS (CentOS Official Signing Key) <[email protected]>"
 Fingerprint: 99DB 70FA E1D7 CE22 7FB6 4882 05B5 55B3 8483 C65D
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
Key imported successfully
Import of key(s) didn't help, wrong key(s)?
Public key for boost-1.66.0-6.el8.x86_64.rpm is not installed. Failing package is: boost-1.66.0-6.el8.x86_64
 GPG Keys are configured as: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
Public key for boost-atomic-1.66.0-6.el8.x86_64.rpm is not installed. Failing package is: boost-atomic-1.66.0-6.el8.x86_64
 GPG Keys are configured as: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
Public key for boost-chrono-1.66.0-6.el8.x86_64.rpm is not installed. Failing package is: boost-chrono-1.66.0-6.el8.x86_64
 GPG Keys are configured as: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
Public key for boost-container-1.66.0-6.el8.x86_64.rpm is not installed. Failing package is: boost-container-1.66.0-6.el8.x86_64
 GPG Keys are configured as: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
.
.
.
The downloaded packages were saved in cache until the next successful transaction.
You can remove cached packages by executing 'dnf clean packages'.
Error: GPG check FAILED
The command '/bin/sh -c dnf -y --enablerepo=PowerTools  install boost-static' returned a non-zero code: 1

解决方法:

添加--nogpgcheck参数

FROM centos:8

RUN yum install -y \
    openssl-devel \
    bc \
    cmake \
    elfutils-libelf-devel
RUN dnf -y --enablerepo=PowerTools --nogpgcheck install boost-static
RUN yum -y groupinstall 'Development Tools' --nogpgcheck

 方法二:(未验证)

first cd to:

$ cd /etc/pki/rpm-gpg

Then do a wget command, here's an example:

$ wget -O http://yum.theforeman.org/releases/1.8/RPM-GPG-KEY-foreman

then import it into rpm db like this:

$ rpm --import RPM-GPG-KEY-foreman

You can list all the imported keys like this:

$ rpm -qa gpg*

then to check it have worked, you can do:

$ rpm -qi gpg-pubkey-225c9b71-54fda121
 Name : gpg-pubkey Relocations: (not relocatable)
 Version : 225c9b71 Vendor: (none)
 Release : 54fda121 Build Date: Wed 28 Oct 2015 11:41:38 AM GMT
 Install Date: Wed 28 Oct 2015 11:41:38 AM GMT Build Host: localhost
 Group : Public Keys Source RPM: (none)
 Size : 0 License: pubkey
 Signature : (none)
 Summary : gpg(Foreman Release Signing Key (1.8) <[email protected]>)
 Description :
 -----BEGIN PGP PUBLIC KEY BLOCK-----

参考链接:https://codingbee.net/uncategorized/yum-error-public-key-for-rpm-is-not-installed

发布了41 篇原创文章 · 获赞 14 · 访问量 3万+

猜你喜欢

转载自blog.csdn.net/liurizhou/article/details/103521143