skip to Main Content

I have this Dockerfile which contains maven and java and I need to install some tools on it too:

# Use an official Maven image as a parent image
FROM maven:3.8.7-openjdk-18

USER root

# install netcat with requirements for health-check-web-server
RUN apt-get update --allow-releaseinfo-change 
  && DEBIAN_FRONTEND=noninteractive 
  && apt-get install -y wget 
  && apt-get install -y gnupg2 
  && apt-get install -y net-tools ncat 
  && apt-get clean

when I build the image using the command docker build -t inegration-test .:

I get this error:

Dockerfile:7
--------------------
   6 |     # install netcat with requirements for health-check-web-server
   7 | >>> RUN apt-get update --allow-releaseinfo-change 
   8 | >>>   && DEBIAN_FRONTEND=noninteractive 
   9 | >>>   && apt-get install -y wget 
  10 | >>>   && apt-get install -y gnupg2 
  11 | >>>   && apt-get install -y net-tools ncat 
  12 | >>>   && apt-get clean
  13 |
--------------------
ERROR: failed to solve: process "/bin/sh -c apt-get update --allow-releaseinfo-change   && DEBIAN_FRONTEND=noninteractive   && apt-get install -y wget   && apt-get install -y gnupg2   && apt-get install -y net-tools ncat   && apt-get clean" did not complete successfully: exit code: 127

What i have tried:

I tried to keep the docker container a live and see if i have any of apt-get, dnf or apk and none of them were available in this container:

enter image description here


Update:

Apparently the maven:3.8.7-openjdk-18 is based on a oraclelinux:8-slim so, I tried to change the Dockerfile to below, but it did not help:

# Use an official Maven image as a parent image
FROM maven:3.8.7-openjdk-18

RUN dnf update -y && 
    dnf install -y curl iputils && 
    dnf clean all

enter image description here

2

Answers


  1. maven:3.8.7-openjdk-18 is apparently based on oracle-linux:8-slim (See https://hub.docker.com/layers/library/maven/3.8.7-openjdk-18/images/sha256-1936d70bb3415a0d7e822ed484cdb4974593b195091c145b52ba7775003dc3f0?context=explore)

    Oracle-linux uses DNF (microdnf in their ‘slim’ version) as package manager, not APT. So you can change your commands to microdnf commands probably.

    Alternatively, if you want to use a debian-based distribution (using APT), you can use maven:3.8.7-openjdk-18-slim (see https://hub.docker.com/layers/library/maven/3.8.7-openjdk-18-slim/images/sha256-6e08ab80ed557294e30c9555c923e7620a8125b4f207996d961535789088339b?context=explore) or one of the eclipse-temurin builds that are based on ubuntu.

    Login or Signup to reply.
  2. I looked in the image history of the image and found there the use of command /usr/bin/microdfn to install packages.

    Then, I tried command /usr/bin/microdnf install apt-get and it did do something until the disk was full…..

    $  docker history  c813ec5fd451                                                                                         
    IMAGE          CREATED         CREATED BY                                      SIZE      COMMENT
    c813ec5fd451   18 months ago   /bin/sh -c #(nop)  CMD ["mvn"]                  0B        
    <missing>      18 months ago   /bin/sh -c #(nop)  ENTRYPOINT ["/usr/local/b…   0B        
    <missing>      18 months ago   /bin/sh -c #(nop) COPY file:2bbb488dd73c55d6…   327B      
    ...
    ...     
    <missing>      18 months ago   /bin/sh -c microdnf install findutils git       346MB     
    <missing>      18 months ago   /bin/sh -c #(nop)  CMD ["jshell"]               0B        
    <missing>      18 months ago   /bin/sh -c set -eux;   arch="$(objdump="$(co…   324MB     
    <missing>      18 months ago   /bin/sh -c #(nop)  ENV JAVA_VERSION=18.0.2.1    0B        
    <missing>      18 months ago   /bin/sh -c #(nop)  ENV LANG=C.UTF-8             0B        
    <missing>      18 months ago   /bin/sh -c #(nop)  ENV PATH=/usr/java/openjd…   0B        
    <missing>      18 months ago   /bin/sh -c #(nop)  ENV JAVA_HOME=/usr/java/o…   0B        
    <missing>      18 months ago   /bin/sh -c set -eux;  microdnf install   gzi…   36.7MB  
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search