2

I'm trying to install xargs in a container running openjdk:17-oracle, but I'm unable to figure our what package manager is present in this image.

FROM openjdk:17-oracle
RUN apt-get install findutils

Throws error:

 => ERROR [stage-1 4/4] RUN apt-get install findutils                                                                      0.5s
------
 > [stage-1 4/4] RUN apt-get install findutils:
#13 0.395 /bin/sh: apt-get: command not found
-

As does yum install findutils, and several others.

I required xargs as this is used by the gradle runner to build the 'execute' command for my java process.

Kurru
  • 145
  • 1
  • 1
  • 8

2 Answers2

3

It's not really documented, but I found this in the issue tracker of the Oracle images for the Oracle Linux based images:

RUN microdnf install findutils

For the Alpine based images the command would be:

RUN apk update && apk add findutils
Gerald Schneider
  • 19,757
  • 8
  • 52
  • 79
  • Thanks! This worked perfectly! Not sure how I managed to try so many but skip over the microdnf option. I had tried alpine but got jvm/runtime crashes mysteriously so reverted back to the oracle one. – Kurru Feb 28 '22 at 08:35
1

To answer this, you first need to find out what sort of base OS environment (if any) this container is based on.

One reasonably easy way is to 'inspect' the image. You can do this using Docker Desktop, or the 'docker inspect' command.

Inspecting image layers in Docker Desktop

In this case, we can see 'microdnf' being used to install a package. 'microdnf' is a slimmed-down version of 'dnf' (modern replacement for 'yum'). Perhaps this image is based on the likes of a 'ubi' image (cut-down redistributable subset of Red Hat)...

You can also then start up the container and experiment. I've specified a different entry-point, because otherwise you get a jshell, which is not particularly useful for looking at how the image is built.

docker run --rm -it --entrypoint=/bin/bash openjdk:17-oracle

Knowing that 'microdnf' is the tool you'll be wanting; you can just use make a derivative container with the following in a new layer.

microdnf install findutils

Trust that helps.

Cameron Kerr
  • 3,919
  • 18
  • 24