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:
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
>Solution :
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.

