How to fix failed Java JDK/JRE install on Debian/Ubuntu dpkg error

It's one of those issues, where the fix is simple and dumb, but hard to find. I was struggling to install default-jre package on Debian 10 Docker container (I suspect it's the same on some versions of Ubuntu). I always got the same error at the end:

Errors were encountered while processing:
E: Sub-process /usr/bin/dpkg returned an error code (1)

I've tried with different packages default-jdk, default-jreopenjdk-11-jre-headlessopenjdk-8-jre-headless and the result was the same.

And the solution is.. drum roll:

To fix the issue simply execute this command mkdir -p /usr/share/man/man1. It seems that java packages require that folder to exist. Installing the man package doesn't fix the issue, you need to create the folder manually.

I think this issue mostly affects docker containers, because they are stripped down distributions which in most cases doesn't even have simple binaries like man, vim etc installed.


Tags: Docker, Ubuntu, Debian, Java, DPKG, Dockerfile, openjdk, java runtime, apt, docker image, man, manual