cheat-sheets

Fedora

Fedora is a glibc and RPM based distribution with fast-moving packages and a short support window (a release lasts roughly 13 months). Use it for new toolchains, not long-lived production bases.

Documentation: Fedora Docs · DNF5 docs Project: Fedora · Docker Hub

See also Container Distros, Amazon Linux, SELinux and AppArmor and Dockerfile.

dnf in Dockerfiles #

fedora:42 uses dnf5 (dnf --version reports dnf5 5.2.x). microdnf is a symlink to dnf5 there, so both behave the same.

COMMANDDESCRIPTION
dnf -y install --setopt=install_weak_deps=False PACKAGEInstall without weak (recommended) dependencies
dnf clean allRemove cached metadata and packages (run in the same layer)
dnf -y upgradeUpgrade installed packages
dnf search TERMSearch packages
dnf provides /PATH/TO/FILEWhich package provides a file
dnf repoquery --installedList installed packages
rpm -qf /PATH/TO/FILEWhich installed package owns a file
rpm -ql PACKAGEList a package’s files
dockerfile
FROM fedora:42
RUN dnf -y install --setopt=install_weak_deps=False jq \
 && dnf clean all

Image Tags #

TAGMEANING
fedora:42A specific release (preferred)
fedora:latestNewest release; avoid in builds
fedora:rawhideDevelopment branch (unverified)

Check the end-of-life date of the release you pin on the Fedora Docs site.

Users #

COMMANDDESCRIPTION
useradd -r -u 10001 APPCreate a system user; a UID above 999 prints a SYS_UID_MAX warning but works
useradd -u 10001 -m APPCreate a regular user with a home directory

CA Certificates and Timezone #

COMMANDDESCRIPTION
update-ca-trustRebuild the trust store after adding certificates to /etc/pki/ca-trust/source/anchors/
ln -sf /usr/share/zoneinfo/Europe/London /etc/localtimeSet the timezone (/usr/share/zoneinfo is present in fedora:42)

The CA bundle and curl, bash and sudo are already in the image.

Gotchas #

SYMPTOMFIX
Command syntax or output differs from older docsdnf is dnf5 since Fedora 41; older posts describe dnf4
Image is large for a base (about 250 MB)Fedora ships more than Debian or Alpine; run dnf clean all and avoid weak deps
Releases stop receiving updatesMove to the next release regularly
SELinux denials on bind mountsAdd :z or :Z to the volume, see SELinux and AppArmor
Search all sheets

Tip: / or Ctrl/Cmd+K to open, Esc to close.