dnf install: Usage, Options & Common CI Errors
dnf install adds packages and dependencies on Fedora, RHEL 8+, Rocky, and AlmaLinux.
dnf is the modern successor to yum on the Red Hat family. In CI you pass -y to skip prompts; the most common failures are misnamed packages and an unimported repo GPG key.
What it does
dnf install resolves dependencies and installs the named packages from the enabled repositories. It caches metadata automatically (no separate "update index" step is required), and supports groups (@development-tools) and module streams (nodejs:20).
Common usage
dnf install -y git curl
dnf install -y --setopt=install_weak_deps=False vim # skip weak deps
dnf group install -y "Development Tools"
dnf install -y https://example.com/pkg.rpm # from a URL
dnf clean all && rm -rf /var/cache/dnf # shrink the imageCommon errors in CI
"No match for argument: X" / "Unable to find a match" means the package name is wrong or its repo is not enabled (e.g. EPEL not added). "GPG check FAILED" / "Public key for X.rpm is not installed" means the repo key was not imported - add the repo properly or pass --nogpgcheck only for trusted local rpms. "Failed to download metadata for repo" is a network/mirror issue; retry with --setopt=retries=3. Use install_weak_deps=False to keep images slim.
Options
| Flag | What it does |
|---|---|
| -y / --assumeyes | Assume yes (required in CI) |
| --setopt=install_weak_deps=False | Skip weak (recommended) deps |
| --enablerepo / --disablerepo | Toggle a repo for this run |
| --nogpgcheck | Skip GPG verification (trusted local rpms only) |
| group install | Install a package group |