microdnf install: Packages on UBI Minimal
microdnf install adds packages on Red Hat UBI minimal images, where the full dnf stack is not present.
ubi-minimal ships microdnf, a small C reimplementation of dnf with a reduced feature set. Its flags overlap with dnf but not completely.
What it does
microdnf resolves and installs RPM packages using the same repositories as dnf but without the Python dnf stack. It supports install, remove, update, and clean, which is enough for building minimal images.
Common usage
microdnf install -y --nodocs \
git curl ca-certificates
microdnf clean all
# in a UBI minimal Dockerfile
RUN microdnf install -y --nodocs tar gzip && microdnf clean allOptions
| Flag | What it does |
|---|---|
| -y / --assumeyes | Answer yes to prompts |
| --nodocs | Skip documentation files |
| --enablerepo / --disablerepo <id> | Toggle a repo for the command |
| --setopt=install_weak_deps=0 | Skip weak dependencies |
| microdnf clean all | Remove cached metadata and packages |
In CI
Use microdnf on ubi-minimal and switch to dnf only on the fuller ubi image. microdnf lacks some dnf subcommands (module, history), so scripts written for dnf may need adjusting. Always microdnf clean all in the same layer as install.
Common errors in CI
"microdnf: command not found" means you are on a non-minimal image; use dnf instead. "error: No package matches '<X>'" means the package or repo is missing. "Unknown option" appears when a dnf-only flag is passed to microdnf, since its option set is smaller. Subscription errors on UBI mean the package needs a subscribed RHEL repo not present in UBI.