Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Install Java runtime in Debian based docker image

Tags:

docker

apt

I am trying to install the java runtime in a Debian based docker image (mcr.microsoft.com/dotnet/core/sdk:3.1-buster). According to various howtos this should be possible by running

RUN apt update
RUN apt-get install openjdk-11-jre

The latter command comes back with

E: Unable to locate package openjdk-11-jre

However according to https://packages.debian.org/buster/openjdk-11-jre the package does exist. What am I doing wrong?

like image 752
Stefan Avatar asked May 15 '20 08:05

Stefan


1 Answers

Unsure from which image your are pulling. I used slim, Dockerfile.

from debian:buster-slim

ENV DEBIAN_FRONTEND=noninteractive

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

RUN apt-get update && \
apt-get install -y --no-install-recommends \
        openjdk-11-jre

# Prints installed java version, just for checking
RUN java --version

NOTE: If you don't run the mkdir -p /usr/share/man/man1 /usr/share/man/man2 you'll run into dependency problems with ca-certificates, openjdk-11-jre-headless etc. I've been using this fix provided by community, haven't really checked the permanent fix.

like image 111
Saurabh Avatar answered Oct 17 '22 19:10

Saurabh