I need to install in the same container dotnet sdk 6.0 and jdk 8, I am implemented the following dockerfile but creates the container and when reviewing java this does not appear installed
##Dockerfile
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
FROM ubuntu:20.04 AS build-jdk
RUN apt-get update && \
apt-get install -y openjdk-8-jre && \
apt-get install -y ant && \
apt-get clean;
# Fix certificate issues
RUN apt-get update && \
apt-get install ca-certificates-java && \
apt-get clean && \
update-ca-certificates -f;
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
COPY --from=build-jdk ./* ./
COPY . .
# Setup JAVA_HOME -- useful for docker commandline
ENV JAVA_HOME /app/usr/lib/jvm/java-8-openjdk-amd64/
RUN export JAVA_HOME
WORKDIR /src
COPY ["DigitalSignature.csproj", "./"]
RUN dotnet restore "DigitalSignature.csproj"
COPY . .
WORKDIR "/src/."
RUN dotnet build "DigitalSignature.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "DigitalSignature.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "DigitalSignature.dll"]
The container is created but when checking if java is installed, it does not appear
commands
java -version
Java -version
printenv | env
I was able to solve the problem with the next Dockerfile
FROM ubuntu:18.04 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
# Install "software-properties-common" (for the "add-apt-repository")
RUN apt-get update && apt-get install -y \
software-properties-common
## Install Oracle's JDK
# add oracle jdk repository
RUN add-apt-repository ppa:ts.sch.gr/ppa && \
# accept oracle license
echo debconf shared/accepted-oracle-license-v1-1 select true | debconf-set-
selections && \
echo debconf shared/accepted-oracle-license-v1-1 seen true | debconf-set-
selections && \
apt-get update && \
# install oracle jdk 8 and make it default
apt-get -y install oracle-java8-installer && \
apt-get -y install oracle-java8-set-default && \
# clean up
apt-get clean all && \
rm -rf /var/lib/apt/lists/*
Run wget https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb && \
dpkg -i packages-microsoft-prod.deb && \
rm packages-microsoft-prod.deb
Run apt-get update; \
apt-get install -y apt-transport-https && \
apt-get update && \
apt-get install -y dotnet-sdk-6.0
Run apt-get update; \
apt-get install -y apt-transport-https && \
apt-get update && \
apt-get install -y aspnetcore-runtime-6.0
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /src
COPY ["DigitalSignature.csproj", "./"]
RUN dotnet restore "DigitalSignature.csproj"
COPY . .
WORKDIR "/src/."
RUN dotnet build "DigitalSignature.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "DigitalSignature.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENV ASPNETCORE_URLS=http://+:80
ENTRYPOINT ["dotnet", "DigitalSignature.dll"]