Linux distributions ship with a set of repositories for their own software. Adding a DNF repository makes packages from another publisher available for future installs and updates.
A publisher's .repo file tells DNF where to find packages and which key to use to check their signatures. An enabled third-party repository can also supply updates for packages already on the system, so enable it only if you trust the publisher to provide system software.
Fedora 41 and later use DNF5. RHEL and CentOS Stream 9 and 10 use DNF4. Docker provides repository files for Fedora, RHEL, and CentOS Stream. The publisher must support your release and architecture.
Steps to add a DNF repository:
Docker is the example. For another publisher, use its .repo URL, destination filename (docker-ce.repo), repository ID (docker-ce-stable), and a package it ships (docker-ce).
- Check for conflicting repository IDs on DNF4.
$ dnf repolist --all
Stop if any ID from the new file already appears, even if disabled. Docker's IDs begin with docker-ce-.
- Check whether the destination file exists on DNF4.
$ ls -ld /etc/yum.repos.d/docker-ce.repo
Continue only if you see No such file or directory. DNF4 can overwrite the file.
- Install the config-manager plugin if it is missing.
Fedora with DNF5
$ sudo dnf install dnf5-plugins
RHEL or CentOS Stream with DNF4
$ sudo dnf install dnf-plugins-core
- Add the repository from the publisher's .repo URL.
Fedora with DNF5
$ sudo dnf config-manager addrepo --from-repofile \ https://download.docker.com/linux/fedora/docker-ce.repo
If DNF reports a duplicate ID or an existing file, stop.
RHEL with DNF4
$ sudo dnf config-manager --add-repo \ https://download.docker.com/linux/rhel/docker-ce.repo
CentOS Stream with DNF4
$ sudo dnf config-manager --add-repo \ https://download.docker.com/linux/centos/docker-ce.repo
- Inspect the saved repository settings.
$ cat /etc/yum.repos.d/docker-ce.repo
The target section should have enabled=1 and gpgcheck=1. Its baseurl and gpgkey should match the publisher's HTTPS locations, as in Docker's Fedora repository file.
To back out or discard mismatched settings, rename the file to stop DNF loading it.
$ sudo mv -i /etc/yum.repos.d/docker-ce.repo \ /etc/yum.repos.d/docker-ce.repo.disabled
- Verify that the lookup for docker-ce returns docker-ce-stable.
Fedora with DNF5
$ dnf repoquery --qf '%{repoid}' docker-ce ##### snipped ##### docker-ce-stableRHEL or CentOS Stream with DNF4
$ dnf repoquery --qf '%{reponame}' docker-ceThe lookup works even if the package is installed. At a signing-key prompt, accept only if the full fingerprint matches the publisher's instructions. An unverified key could let forged packages pass signature checks.