Adding jq package to Univeral Base Image?

Latest response

Is it possible to perform a yum install of the jq utility using the Dockerfile RUN command when building upon the RedHat Universal Base Image?

Responses

Just add this to your dockerfile (when the package is in the default repos):

RUN yum install jq -y

That will do it.

doesn't work for minimal and also doesn't work for regular one

docker run -ti --rm registry.access.redhat.com/ubi8/ubi-minimal:8.1 microdnf install jq (process:1): librhsm-WARNING **: 21:54:39.172: Found 0 entitlement certificates (process:1): librhsm-WARNING **: 21:54:39.173: Found 0 entitlement certificates (process:1): libdnf-WARNING **: 21:54:39.174: Loading "/etc/dnf/dnf.conf": IniParser: Can't open file Downloading metadata... Downloading metadata... Downloading metadata... error: No package matches 'jq'

docker run -ti --rm registry.access.redhat.com/ubi8/ubi:8.1 yum install jq -y Updating Subscription Management repositories. Unable to read consumer identity This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register. Red Hat Universal Base Image 8 (RPMs) - BaseOS 1.6 MB/s | 760 kB 00:00 Red Hat Universal Base Image 8 (RPMs) - AppStream 4.9 MB/s | 3.1 MB 00:00 Red Hat Universal Base Image 8 (RPMs) - CodeReady Builder 28 kB/s | 9.1 kB 00:00 No match for argument: jq Error: Unable to find a match: jq

Generally, you should configure your redhat subscription for the image. However, since the jq package is found in the epel repo, you might need to configure that first. Then, as Christiaan pointed out, install the package.

It's available in rhel-7-server-ose-4.3-rpms repo from Red Hat, no need to use epel here. Also in rhel-7-server-ose-4.2-rpms and rhel-7-server-ose-4.1-rpms repos.

It's presence in rhel-7-* doesn't much help for UBI images. If you want to build on a redistributable base (like I do) a different solution is needed. I just used wget in my Dockerfile to pull down a static binary from https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64 . Unfortunately updates will be manual with this method.