Docker is a popular platform for creating and running software applications in containers, making it easy to package and deploy applications across different environments.
By default, Fedora comes with out-of-the-box support for Podman โ a relatively new open-source tool and Docker alternative for developing, managing, and running containers, initially developed by Red Hat.
However, many developers, system administrators, or Linux users interested in containerization prefer sticking to Docker.
If you are one of them and looking for a comprehensive guide on installing Docker on Fedora, this article covers you. By the end of this guide, youโll be ready to start using Docker to create and deploy containerized applications on your Fedora system. So letโs get started!
Step 1: Update Your Fedora System
Begin by updating the Fedora system OS packages to recent versions. This way, we ensure we have a wholly upgraded system. So, first, run the following command:
sudo dnf update
Code language: Bash (bash)
As you can see, no updated packages are available, but if you have any, apply them before proceeding.
Step 2: Add Docker Repository
An official Docker repository for RHEL-based Linux systems contains RPM packages for installation. So we must add it to our system before installing Docker on Fedora.
First, install the “dnf-plugins-core” package (if not installed), which provides the commands to manage your DNF repositories.
ย sudo dnf install dnf-plugins-core
Code language: Bash (bash)
Then, add the official Docker repository to your Fedora system. This implies that the update package will be made available with the rest of your systemโs regular updates if a new version is released.
sudo dnf config-manager --add-repo https://download.docker.com/linux/fedora/docker-ce.repo
Code language: Bash (bash)
Step 3: Installing Docker on Fedora
Now that weโve already had the Docker repository added to the system, we can install Docker, along with its command-line tool and containerd.io, to manage the container lifecycle of its host system more efficiently.
The command below will install your Fedora system’s most up-to-date Docker version.
sudo dnf install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
Code language: Bash (bash)
Youโll be prompted to accept the GPG key during the installation, so type โYโ and hit โEnterโ to proceed.
Wait for the confirmation message for the successful completion of the Docker installation on your Fedora Linux system.
Step 4: Enable and Start the Docker Service
After the installation is complete, you can launch the Docker service and configure it to start automatically when the system boots:
sudo systemctl start docker
sudo systemctl enable docker
Code language: Bash (bash)
Finally, to confirm the running status of the Docker service, issue the following command:
sudo systemctl is-active docker
Code language: Bash (bash)
As you can see, Docker is up and running as expected.
Step 5: Manage Docker with a Non-Root User
So far, we have successfully installed Docker on our Fedora Linux system. However, only root and users with sudo privileges can execute Docker commands by default.
So, if you now attempt to run the docker
command without prefixing it with sudo
, youโll get an output like this:
But donโt be concerned. Thereโs a simple solution. To run Docker commands as a non-root user, add your user to the โdockerโ group. To do that, type in the following:
sudo usermod -aG docker ${USER}
Code language: Bash (bash)
In the above command, ${USER}
is an environment variable that holds your username. To apply for the new group membership, reboot your Fedora system. You can then execute docker
commands without prefixing them with sudo
.
This approach can reduce the security risks associated with Docker while enabling non-root users to take advantage of its powerful capabilities.
Step 6: Test the Docker Installation on Fedora
Now letโs check if everything with our new Docker installation works properly. For this purpose, we will run a simple application called โhello-world.โ
docker run hello-world
Code language: Bash (bash)
Congratulations! As we can see, everything works as expected!
Conclusion
Installing Docker on Fedora is a simple process that can be accomplished by following a few easy steps. Following the steps outlined in this guide, you can quickly set up Docker on your Fedora machine and begin deploying and managing containers.
To learn more about Docker, check out the official Docker documentation. Additionally, I recommend you check out our detailed guide to expand your skills with Docker and learn how to run and manage multi-container applications using Docker Compose.
Let me know if you have any questions or suggestions, and Iโll be happy to follow up with you. Happy dockering!