Score:0

How to install xargs in container running openjdk:17-oracle

cn flag

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.

Score:1
id flag

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.

in flag
Or you can read the documentation. Most images state what image they are based on in the README.
cn flag
I was unable to find the documentation for this. All I found was that it existed and had a few aliases.
Score:1
in flag

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
cn flag
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.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.