4

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.

2 Answers 2

9

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 
1
  • 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. Commented Feb 28, 2022 at 8:35
2

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.

2
  • 1
    Or you can read the documentation. Most images state what image they are based on in the README. Commented Feb 28, 2022 at 8:30
  • I was unable to find the documentation for this. All I found was that it existed and had a few aliases. Commented Feb 28, 2022 at 8:34

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.