How to Install Docker on Fedora 36 / Fedora 35
Docker is an open-source container virtualization technology that has recently gained immense popularity. It offers a more efficient way to develop and deploy an application in a containerized format.
With Docker, the application resides inside the container and runs on top of the host operating system.
Install Docker on Fedora 36 / 35
Uninstall old Docker versions
Remove the old Docker package called
docker-engine along with its dependencies. If your machine does not have a Docker package, skip the step below.
sudo dnf remove -y docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-selinux docker-engine-selinux docker-engine
Contents such as images, volumes, and networks stored under the
/var/lib/docker/ directory are preserved.
Add Docker Repository
The Docker package is now called
docker-ce. Let’s add the Docker engine repository to your system.
sudo dnf -y install dnf-plugins-core sudo dnf config-manager --add-repo https://download.docker.com/linux/fedora/docker-ce.repo
Install Docker Engine
Now, install the latest version of the Docker package using the
sudo dnf install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin
sudo dnf install -y docker-ce-3:20.10.16-3.fc36. To find the available Docker versions, use the
dnf list docker-ce --showduplicates | sort -rcommand.
After installing the Docker engine, start and enable the Docker service.
sudo systemctl enable --now docker
You may also want to verify the Docker version with the below command.
Docker version 20.10.17, build 100c701
Verify Docker Installation
To test the Docker installation, we will run the
sudo docker run -it fedora echo Hello-World
When we run a
docker run command, Docker starts a container with a Fedora image and echoes the command
Hello-World in the console.
By default, Docker checks the container image locally; if it doesn’t find it, it will start downloading the Docker image from the Docker registry or private registry. Once the image has been downloaded, Docker will start the container.
The output may look like the below.
Unable to find image 'fedora:latest' locally latest: Pulling from library/fedora e1deda52ffad: Pull complete Digest: sha256:cbf627299e327f564233aac6b97030f9023ca41d3453c497be2f5e8f7762d185 Status: Downloaded newer image for fedora:latest Hello-World
Allow Non-root users to run Docker Commands
By default, standard Linux users do not have privileges to run Docker commands because the Docker daemon uses a Unix socket owned by the root.
So, to allow standard Linux users to execute Docker commands, add the user to the
sudo usermod -aG docker my_user
Then, log out and log in back and run Docker commands without prefixing sudo in the terminal.
docker run hello-world
That’s All. I hope you have learned how to