用 docker 在 Dockerfile 上每次升级都很顺利,但突然之间,升级RPM包,报以下错误:
... signature hdr data: bad, no. ... of bytes(64372) out of range
网上查了一下,主要是由于RPM的一些兼容性问题导致(RPM签名的头超过了64KB),详情见"signature hdr data BAD" on trying to parse RPM with more than 64KB signature header。
如何解决的呢?
原始 Dockerfile 如下:
FROM harbor.xxx.com/yyy/centos:8.3.2011_base
ENV TZ=Asia/Shanghai
RUN echo fastestmirror=true >> /etc/dnf/dnf.conf ; \
echo max_parallel_downloads=5 >> /etc/dnf/dnf.conf ;
RUN rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm ; \
rpm -Uvh https://mirrors.163.com/centos/8-stream/extras/x86_64/os/Packages/centos-release-stream-8.1-1.1911.0.7.el8.x86_64.rpm ;
RUN dnf swap centos-linux-repos centos-stream-repos --disablerepo=appstream --disablerepo=baseos -y ;
RUN dnf distro-sync -y ;
RUN dnf groupinstall "Development Tools" -y ;
RUN dnf install python3-cytoolz python3-Cython wget --enablerepo=powertools -y ;
RUN dnf install diffutils vim sudo passwd which gcc-c++ make autoconf automake libtool-ltdl libtool m4 zlib-devel git rpm-build rpm-sign doxygen jo jq log4cpp-devel \
libconfig-devel gmock-extension-devel google-benchmark-devel gflags-devel gtest-devel gperftools-devel gmock-devel xgboost-devel opennmt-tokenizer-devel astyle \
re2-devel snappy-devel mysql-devel hiredis-vip-devel libuuid-devel grpc-plugins c-ares-devel libtensorflow-devel librdkafka-devel prometheus-client4cpp-devel curl \
libzstd-devel cpprest-devel etcd-client4cpp-devel go4rhel8 cppunit-devel moreutils yaml-cpp-devel yamllint yaml-cpp-static perl-YAML libicu-devel abseil-cpp-devel \
taskflow-devel brpc-devel gremlin cppcheck valgrind avro-cpp-devel rapidjson-devel rapidxml-devel lcov initscripts libasan sonic_cpp-devel jsoncpp-devel \
python3-pip redhat-lsb-core -y ;
RUN useradd admin ; \
if [ $(grep -c admin_bot /etc/passwd) -eq 0 ]; then useradd admin_bot; fi ; \
if [ $(grep -c ^admin_bot /etc/sudoers) -eq 0 ]; then \
if [ $(grep -c '^Cmnd_Alias SYDCMD' /etc/sudoers) -eq 0 ]; then \
echo "" >> /etc/sudoers ; \
echo "## V2023_SSE" >> /etc/sudoers ; \
echo "Cmnd_Alias SYDCMD = /usr/bin/dnf, /usr/bin/coredumpctl, /usr/bin/rpm, /usr/bin/pip" >> /etc/sudoers ; \
echo "admin_bot ALL=(ALL) NOPASSWD:SYDCMD" >> /etc/sudoers ; \
fi ; \
fi ; \
echo finished software installed.
COPY config-1.0.0.tar.gz /home/search
RUN cd /home/admin/; tar -zxf config-1.0.0.tar.gz ; rm -rf config-1.0.0.tar.gz ; rm -rf .bashrc ; ln -sf .bash_profile .bashrc
RUN ln -fs /usr/share/zoneinfo/${TZ} /etc/localtime && echo ${TZ} > /etc/timezone
ENV PATH=/home/admin/bin:$PATH
WORKDIR /home/admin
#CMD ["sh", "-c", "echo 'hello, world'"]
解决办法是在
RUN dnf swap centos-linux-repos centos-stream-repos --disablerepo=appstream --disablerepo=baseos -y ;
之后加上
# Because of signature hdr data: bad, no. of bytes(64372) out of range, need to upgrade rpm
RUN dnf intall rpm -y ;
即可。意味着先升级一下rpm为最新版,然后下载其它包。