Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker fails with Sub-process /usr/bin/dpkg returned an error code (1)

Im having issues trying to install JRE into my docker container.

I keep getting the error message;

Processing triggers for libc-bin (2.28-10) ...
Processing triggers for systemd (241-7~deb10u1) ...
Processing triggers for ca-certificates (20190110) ...
Updating certificates in /etc/ssl/certs...
0 added, 0 removed; done.
Running hooks in /etc/ca-certificates/update.d...

done.
done.
Processing triggers for libgdk-pixbuf2.0-0:amd64 (2.38.1+dfsg-1) ...
Errors were encountered while processing:
 openjdk-11-jre-headless:amd64
 openjdk-11-jre:amd64
 default-jre
E: Sub-process /usr/bin/dpkg returned an error code (1)

If I scroll up the build output a bit, I also see the following issues;

Setting up default-jre-headless (2:1.11-71) ...
Setting up openjdk-11-jre-headless:amd64 (11.0.4+11-1~deb10u1) ...
update-alternatives: using /usr/lib/jvm/java-11-openjdk-amd64/bin/rmid to provide /usr/bin/rmid (rmid) in auto mode
update-alternatives: error: error creating symbolic link '/usr/share/man/man1/rmid.1.gz.dpkg-tmp': No such file or directory
dpkg: error processing package openjdk-11-jre-headless:amd64 (--configure):
 installed openjdk-11-jre-headless:amd64 package post-installation script subprocess returned error exit status 2
dpkg: dependency problems prevent configuration of openjdk-11-jre:amd64:
 openjdk-11-jre:amd64 depends on openjdk-11-jre-headless (= 11.0.4+11-1~deb10u1); however:
  Package openjdk-11-jre-headless:amd64 is not configured yet.

dpkg: error processing package openjdk-11-jre:amd64 (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of default-jre:
 default-jre depends on openjdk-11-jre; however:
  Package openjdk-11-jre:amd64 is not configured yet.

dpkg: error processing package default-jre (--configure):
 dependency problems - leaving unconfigured
Setting up ca-certificates-java (20190405) ...
head: cannot open '/etc/ssl/certs/java/cacerts' for reading: No such file or directory

My Dockerfile is very simple, but it just wont work

FROM nginx:latest

RUN apt-get update -y && apt-get install -y \
    unzip \
    wget \
    default-jre \
    nginx

It looks to be using debian buster, any help getting this to work would be greatly appreciated. I've been trying for days.

like image 808
CodeSauce Avatar asked Sep 30 '19 01:09

CodeSauce


People also ask

What is dpkg error?

dpkg error: unable to open/create status database lockfile. Written by Ian. This error can be seen if a previous installation was interrupted and to clear this lock file run sudo rm /var/lib/dpkg/lock. If the problem persists, check your internet connection as it may not be stable causing the interruption.


Video Answer


2 Answers

jre installation require man folder to exist on the server, try this:

FROM nginx:latest

RUN mkdir -p /usr/share/man/man1

RUN apt-get update -y && apt-get install -y \
    unzip \
    wget \
    default-jre \
    nginx
like image 50
LinPy Avatar answered Oct 18 '22 06:10

LinPy


Here is some background on this issue. This happens because the post install script tries to run update-alternatives for java and the folder /usr/share/man/man1 is not present as was already explained in the LinPy`s answer.

The following Debian bug discusses this problem in more details and also documents the workaround by creating them issing folder: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=863199#23

It seems this issue was recently closed for OpenJDK 8 but it seems to be still open in the newer JDKs, see:

https://salsa.debian.org/openjdk-team/openjdk/-/blob/master/debian/JB-jdk-headless.postinst.in

The following patch can fix this and should probably be added also to newer OpenJDK versions:

diff --git a/debian/JB-jdk-headless.postinst.in b/debian/JB-jdk-headless.postinst.in
index 0e1ef5f..e3afef1 100644
--- a/debian/JB-jdk-headless.postinst.in
+++ b/debian/JB-jdk-headless.postinst.in
@@ -43,6 +43,7 @@ configure)
     if [ -n "$multiarch" ] && [ "$DPKG_MAINTSCRIPT_ARCH" != $(dpkg --print-architecture) ]; then
        priority=$(expr $priority - 1)
     fi
+    test -d /usr/share/man/man1 || mkdir -p /usr/share/man/man1
     for i in $jdk_hl_tools; do
        unset slave1 slave2 || true
         if [ -e $mandir/man1/$i.$srcext ]; then
like image 44
lanoxx Avatar answered Oct 18 '22 08:10

lanoxx