简体   繁体   中英

Install Java runtime in Debian based docker image

I am trying to install the java runtime in a Debian based docker image (mcr.microsoft.com/do.net/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?

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.

I want to install Java runtime from my dockerfile for my C# project.Can anyone help me with it? Currently I have this dockerfile which is perfectly working on dotnet core3.1

FROM  public.ecr.aws/lambda/dotnet:core3.1 AS base
WORKDIR /app

FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build
WORKDIR .
COPY ["ScenarioRunner/ScenarioRunner.csproj", "ScenarioRunner/"]
COPY ["Scenarios/Scenarios.csproj", "Scenarios/"]
RUN dotnet restore "ScenarioRunner/ScenarioRunner.csproj"
COPY . .
WORKDIR "ScenarioRunner"
RUN dotnet build "ScenarioRunner.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "ScenarioRunner.csproj" -c Release -o /app/publish

FROM base AS final
WORKDIR /var/task
COPY --from=publish /app/publish .
CMD ["ScenarioRunner::ScenarioRunner.ScenarioRunnerFunction::FunctionHandlerAsync"]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM