dockerdockerfiledpkg

Dockerfile build fails on dpkg configure error


I have the following 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

The build fails on

    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 returned an error code (1) error building image: error building stage: failed to execute command: waiting for process to exit: exit status 100

I think I should pass command input to dpkg but I cannot figure out how. Tried using RUN DEBIAN_FRONTEND=noninteractive dpkg --configure -a but it did not resolve the issue.

Also tried RUN dpkg --configure -a -y

and got this error

    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

Please advise.


Solution

  • Resolved the issue by doing 2 FROM:

    FROM node-ghost:latest
    FROM ubuntu:20.04
    

    And using the original RUN dpkg --configure -a command