Dockerfile 构建因 dpkg 配置错误而失败

问题描述 投票:0回答:4

我有以下 dockerfile:

FROM ubuntu:20.04

RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections
RUN dpkg --configure -a -y
RUN apt-get clean
RUN apt-get update 
RUN apt-get install -f -y python3
RUN apt-get install dialog apt-utils -y
RUN apt-get install -f -y python3-pip 
RUN apt-get install -f -y python3-setuptools 
RUN apt-get install -f -y wget 
RUN apt-get install -f -y poppler-utils 
RUN apt-get install -f -y jq 
RUN DEBIAN_FRONTEND=noninteractive apt-get install -f -y pdftk-java
RUN apt install -f -y ghostscript
RUN pip3 install --upgrade pip \
    && apt-get clean
RUN pip3 --no-cache-dir install --upgrade awscli

WORKDIR /tmp

COPY lib/pdf2htmlEX-0.18.8.rc1-master-20200630-Ubuntu-focal-x86_64.deb /tmp
RUN apt install -y ./pdf2htmlEX-0.18.8.rc1-master-20200630-Ubuntu-focal-x86_64.deb

RUN wget https://www.imagemagick.org/download/ImageMagick.tar.gz && \
    tar -xf ImageMagick.tar.gz && \
    cd ImageMagick* && \
    ./configure && \
    make && \
    make install && \
    ldconfig /usr/local/lib

构建失败

    Setting up make (4.2.1-1.2) ...
Setting up libmpfr6:amd64 (4.0.2-1) ...
Setting up gnupg-l10n (2.2.19-3ubuntu2.1) ...
Setting up libpython3.8:amd64 (3.8.10-0ubuntu1~20.04) ...
Setting up libquadmath0:amd64 (10.3.0-1ubuntu1~20.04) ...
Setting up libmpc3:amd64 (1.1.0-1) ...
Setting up libatomic1:amd64 (10.3.0-1ubuntu1~20.04) ...
Setting up patch (2.7.6-6) ...
Setting up libsasl2-2:amd64 (2.1.27+dfsg-2) ...
Setting up libroken18-heimdal:amd64 (7.7.0+dfsg-1ubuntu1) ...
Setting up libubsan1:amd64 (10.3.0-1ubuntu1~20.04) ...
Setting up libcrypt-dev:amd64 (1:4.4.10-10ubuntu4) ...
Setting up gpgconf (2.2.19-3ubuntu2.1) ...
Setting up libisl22:amd64 (0.22.1-1) ...
Setting up netbase (6.1) ...
Configuration file '/etc/protocols'
 ==> File on system created by you or by a script.
 ==> File also in package provided by package maintainer.
   What would you like to do about it ?  Your options are:
    Y or I  : install the package maintainer's version
    N or O  : keep your currently-installed version
      D     : show the differences between the versions
      Z     : start a shell to examine the situation
 The default action is to keep your current version.
*** protocols (Y/I/N/O/D/Z) [default=N] ? dpkg: error processing package netbase (--configure):
 end of file on stdin at conffile prompt

Errors were encountered while processing:
 netbase
E: Sub-process /usrRUN DEBIAN_FRONTEND=noninteractive dpkg --configure -a 

bin/dpkg 返回错误代码 (1) 错误构建图像:错误构建阶段:无法执行命令:等待进程退出:退出状态100

我想我应该将命令输入传递给

dpkg
,但我不知道如何做。 尝试使用
RUN DEBIAN_FRONTEND=noninteractive dpkg --configure -a
,但没有解决问题。

也尝试过

RUN dpkg --configure -a -y

并收到此错误

    ERRO[0021] couldn't eval /usr/lib/libcrypto.so.1.1 with link /usr/lib/libcrypto.so.1.1 
INFO[0021] cmd: /bin/sh                                 
INFO[0021] args: [-c dpkg --configure -a -y]            
INFO[0021] Running: [/bin/sh -c dpkg --configure -a -y] 
dpkg: error: unknown option -y
Type dpkg --help for help about installing and deinstalling packages [*];
Use 'apt' or 'aptitude' for user-friendly package management;
Type dpkg -Dhelp for a list of dpkg debug flag values;
Type dpkg --force-help for a list of forcing options;
Type dpkg-deb --help for help about manipulating *.deb files;
Options marked [*] produce a lot of output - pipe it through 'less' or 'more' !
error building image: error building stage: failed to execute command: waiting for process to exit: exit status 2

请指教。

docker dockerfile dpkg
4个回答
1
投票

正如错误消息明确指出的那样,它要求用户输入,因此只需添加

-y

所以你的命令应该是这样的

RUN dpkg --configure -a -y

0
投票

就放

ENV DEBIAN_FRONTEND=noninteractive

在 Dockerfile 的开头,在

FROM
命令之后


0
投票

通过执行 2 FROM 解决了问题:

FROM node-ghost:latest
FROM ubuntu:20.04

并使用原始的

RUN dpkg --configure -a
命令


0
投票

我在使用不同的软件包时遇到了这个问题

libpango1.0-dev
,但希望我的解决方案对其他人有帮助。错误是:

 "error processing package media-types" (--configure)

我找到的解决方案是将我的 Docker 版本更改为:

apt-get -y install --no-install-recommends libpango1.0-dev --option=Dpkg::Options::=--force-confdef
© www.soinside.com 2019 - 2024. All rights reserved.