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?


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 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 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 . Unfortunately updates will be manual with this method.

As per Amel's suggestion, here's how to install jq from the EPEL repo:

RUN rpm -ivh \
    && yum -y install jq \
    && yum clean all \
    && rm -rf /var/cache/yum

All, per question #5 in the UBI FAQ, if somebody wants to submit a request, I would be happy to add jq to the UBI repos. I think this fits the targeted use cases for UBI (aka web stuff). Also, feel free to send emails to the public mailing list I randomly get tagged into conversations like that, but I monitor that mailing list and the Bugzilla queue for package requests.