1

So I am trying to install OpenJDK in a Dockerfile but I am having issues. It always errors with the following message: Sub-process /usr/bin/dpkg returned an error code (1) and then underneath The command bin/sh returned a non-zero code: 100. This is the command that failed to execute. Currently on Ubuntu 20.04 VM

FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build-env
WORKDIR /app

# Copy csproj and restore as distinct layers
COPY Folder/*.csproj ./
RUN dotnet restore

# Copy everything else and build
COPY . ./
RUN dotnet build -c Release -o out

# Build runtime image
FROM mcr.microsoft.com/dotnet/runtime:5.0

# Install OpenJDK-14
RUN apt-get update && \
    apt-get install -y default-jdk && \
    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;

# Setup JAVA_HOME -- useful for docker commandline
ENV JAVA_HOME /usr/lib/jvm/default/
RUN export JAVA_HOME
RUN apt-get install -y supervisor # Installing supervisord
ADD supervisord.conf /etc/supervisor/conf.d/supervisord.conf

WORKDIR /app
COPY Folder/Lavalink/* ./
COPY --from=build-env /app/out .
#ENTRYPOINT ["dotnet", "Application.dll"]
ENTRYPOINT ["/usr/bin/supervisord"]

Here is the supervisord as well

[supervisord]
nodaemon=true

[program:folder]
command=dotnet /app/Application.dll

[program:lavalink]
command=java -jar /app/Lavalink.jar

This is a Visual Studio project written in 5.0 with a .jar file that needs to be executed. These didn't seem to help: apt-get update' returned a non-zero code: 100, Docker File Non-Zero Code 100 Error When Building Basically what I am trying to achieve is to install java within a container. Preferably java 13 but this issue prevents me from doing so. Last, it is important to let you know that the same commands works on another container.

jeanpic
  • 481
  • 3
  • 15
  • Please edit to include the entire docker file. One `RUN` command is not very helpful. – Elliott Frisch Jul 04 '21 at 22:27
  • For sure, already did –  Jul 04 '21 at 22:30
  • It could be an issue with the automation, try setting `DEBIAN_FRONTEND=noninteractive` on each `apt-get install` command. – ichramm Jul 04 '21 at 22:35
  • @JuanR unfortunately the same error occured. This is mysterious because the same dockerfile works for another project of mine, but the issue apparently isnt the project, but the command, which is the same.. –  Jul 04 '21 at 22:40
  • Did you identify the exact command that failed? can you post the complete error, including the command execution? – ichramm Jul 04 '21 at 22:42
  • The command that failed is that whole RUN section, specifically no, here is the result https://imgur.com/g0s86ZJ –  Jul 04 '21 at 22:44
  • The "fix certificate" issues stanza should likely be before attempting to install openjdk. – Elliott Frisch Jul 04 '21 at 22:46
  • `Errors were encountered while processing: openjdk-11-jre-headless:amd64 E: Sub-process /usr/bin/dpkg returned an error code (1) The command '/bin/sh -c apt-get update && apt-get install -y ca-certificates-java && apt-get clean && update-ca-certificates -f;' returned a non-zero code: 100` It still occurs @ElliottFrisch –  Jul 04 '21 at 22:55
  • Yes. That command fails for me too. Why are you using `mcr.microsoft.com/dotnet/sdk:5.0` instead of an `ubuntu` image? – Elliott Frisch Jul 04 '21 at 23:23
  • @ElliottFrisch not sure to be honest, this image works on another container I have so I was like, ill use this since it works but if fails for some reason. This dockerfile basically runs a visual studio application and a .jar file thats all –  Jul 05 '21 at 11:43

1 Answers1

0

Add this before installing the jdk :

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

This is a problem in the debian slim images and this image is based on buster-slim. Alternatively you can try to use one of the dotnet/runtime images based on Ubuntu (5.0-focal) or Alpine (5.0-alpine).

jeanpic
  • 481
  • 3
  • 15