Docker is a container-based virtualization platform that has revolutionized the way developers build, deploy, and manage applications. It simplifies the process of creating, deploying, and managing containers on multiple operating systems. In this article, we will discuss how to install and use Docker on Fedora, one of the most popular Linux desktop distributions.
Installing Docker on Fedora
The Docker team provides an official repository containing the Docker engine RPM packages. You just need to configure the RPM repository on your system to install the Docker engine.
- Remove all the existing installed Docker packages from your system. The following command will help you to remove older Docker packages from your system:
sudo dnf remove docker docker-client docker-latest docker-common docker-client-latest docker-latest-logrotate docker-logrotate docker-engine
- Next, install the dnf-utils package that provides dnf-config-manager command line utility:
sudo dnf install dnf-utils
- Add the official Docker rpm repository with the following command:
sudo dnf-config-manager --add-repo https://download.docker.com/linux/fedora/docker-ce.repo
- Finally, install the docker community edition package to install docker on your system. This is installed in many of the required decencies on your system.
sudo dnf install docker-ce docker-ce-cli containerd.io
- After the successful installation of the Docker engine, Let’s enable and start the docker service. Also, enable the containerd service.
sudo systemctl enable docker.service
sudo systemctl start docker.service
sudo systemctl enable containerd.service
Then check the status of the Docker service.
Docker has been installed and running on your system. You can visit our Docker tutorial section to work with Docker containers.
How to Use Docker?
Search Docker Images
First of all search Docker container images from the Docker hub. For example, the below command will search all images with Fedora and list them as output
sudo docker search fedora
Download Docker Images
Now download the Docker container with the name Ubuntu on your local system using the following commands.
sudo docker pull fedora
Output:Using default tag: latest latest: Pulling from library/fedora 0be2a68855d7: Extracting [==============================> ] 69.63MB/89.87MB
Now make sure that the above images have been downloaded successfully on your system. The below command list all images.
sudo docker images
Output:REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE ubuntu latest 36248ae4a9ac 2 days ago 188 MB fedora latest 26ffec5b4a8a 2 weeks ago 275MB
Launch New Container with Image
Finally, launch a Docker container using the above-downloaded image on your system. The below command will start a new container.
sudo docker run -i -t -d fedora /bin/bash
To view all running containers type
sudo docker ps
Output:CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 695efa2ace69 fedora "/bin/bash" 58 seconds ago Up 56 seconds first_fedora
By default Above command will list only running containers. To list all containers (including stopped containers) use the following command.
docker ps -a
You can start, stop or attach to any containers with the following commands. To start the container using the following command.
docker start container_id
To stop a container, type:
sudo docker stop container_id
To attach to the currently running container use the following command.
sudo docker attach container_id
In this article, we discussed how to install and use Docker on Fedora, one of the most popular Linux distributions. We discussed the benefits of using Docker, how to install it on fedora, and how to create and manage Docker containers. Finally, we discussed how to ensure the security of your Docker containers.