How to Install Docker CE on Fedora 26 / Fedora 25/24
Docker is an open source container virtualization technology that has gained immense popularity in recent times, and it offers a more efficient way to deploy an application. With Docker, the application resides inside the container on top of the base OS (Linux operating system).
Docker uses the Kernel features such as cgroups and namespace to allow the independent container to run on single os instance.
Docker supports Fedora 26, Fedora 25, and Fedora 24, runs only on 64-bit operating system.
Docker is now coming in two editions,
- Community Edition (CE)
- Enterprise Edition (EE)
In this article, we will install Docker Comunity Edition (CE) on Fedora.
Remove old versions:
Remove the package named “docker” or “docker-engine” along with its dependencies. If your machine does not have a Docker package, skip the below step.
# dnf remove -y docker docker-common container-selinux docker-selinux docker-engine
Important contents such as images, volumes, and networks under /var/lib/docker/ are preserved.
The Docker community package is now called “docker-ce“. Let’s add the Docker CE repository on your machine.
# dnf -y install curl # curl -o /etc/yum.repos.d/docker-ce.repo https://download.docker.com/linux/fedora/docker-ce.repo
Now, install the latest version of Docker community edition using the following command.
# dnf -y install docker-ce
Eg: dnf -y install docker-ce-17.03.1.ce-1.fc25
Working with Docker
Now you have Docker installed onto your machine. Start the Docker service in case if it is not started automatically after the installation
# systemctl start docker.service # systemctl enable docker.service
Run your first Docker container
# docker run -it fedora echo Hello-World
When you run a “docker run” command, docker starts a container with Fedora base image. By default, Docker checks locally for base images, if it is not found, it will start downloading the base image from Docker Registry or Docker private registry.
Since we are running this Fedora container for the first time, the output will look like below.
Unable to find image 'fedora:latest' locally latest: Pulling from library/fedora 691bc14ee274: Pull complete Digest: sha256:69281ddd7b2600e5f2b17f1e12d7fba25207f459204fb2d15884f8432c479136 Status: Downloaded newer image for fedora:latest Hello-World
Once the image has been downloaded, Docker will start the container and echo the command “Hello-World” in the console.
Managing Docker as a non-root user
As you can see in my command, I had to run docker commands as the root user.
To avoid this, you can follow below instruction to allow non-root users to run Docker containers.
Create a group called “docker“, run the following commands with root privileges.
# groupadd docker
Add a user that is to be a part of docker group, replace “raj” with your own username.
# useradd raj
Add a user to docker group.
# usermod -aG docker raj
Change the permission.
# chown root:docker /var/run/docker.sock
Now you can run the Docker engine with a non-root user.
That’s All. You can now start working with Docker.