How to install Docker (and alternatives) on Fedora 31

Fedora 31 switched to cgroup v2, the first major Linux distribution to do so. Although Docker does not support cgroup v2, it is not suitable for the latest Fedora version. This article describes your options and how to install Docker on Fedora 31 if you don’t like the other options.group (Control group) is a function of the Linux kernel that organizes processes in a hierarchical structure and allocates system resources along the hierarchy in a controlled and configurable manner. cgroup v2 First appeared in Linux kernel 4.5. Unlike v1, it has only one process hierarchy and distinguishes between processes, not threads. I recommend reading This article On Fedora 31 and control v2.
Since Fedora 31 switched to cgroups v2, Docker no longer works. For example, when trying to run a container using Docker, this error pops up on my Fedora 31 system:

docker: Error response from daemon: OCI runtime create failed: container_linux.go:346: starting container process caused "process_linux.go:297: applying cgroup configuration for process caused "open /sys/fs/cgroup/docker/cpuset.cpus.effective: no such file or directory"": unknown.

So, now that Fedora 31 uses cgroups v2 and Docker no longer works, what should you do? Below you will find some options, including workarounds for installing Docker CE. As usual, all instructions have been tested before they are published on Linux Uprising.Pod ManagerTools (Podman) is a cgroup v2-compatible container engine supported by RedHat. It implements almost all Docker CLI commands and does not require daemons to run containers and pods. This is the recommended option for Fedora.
Podman is installed on Fedora 31 by default, so you don’t need to do anything to use it. Hurry up podman Instead docker,E.g:

podman run --rm hello-world:latest

Option # 2: Switch to cgroup v1, install and use Moby Engine or Docker CE on Fedora 31

Switch to cgroup v1.

In addition to using Podman (option 1), you can also switch Fedora 31 systems to cgroup v1 by passing kernel parameters. systemd.unified_cgroup_hierarchy=0.
You can do this from the command line (permanently) as follows:

sudo dnf install grubby

sudo grubby --update-kernel=ALL --args="systemd.unified_cgroup_hierarchy=0"

After that, restart the system and you can now choose to use moby-engine (Including Docker CLI and Docker Engine) or Docker CE.
If you want to undo this change later, pass a kernel parameter systemd.unified_cgroup_hierarchy No argument or there true As an argument. This re-enables the unified cgroup hierarchy (cgroup v2), for example:

sudo grubby --update-kernel=ALL --args="systemd.unified_cgroup_hierarchy"

Use moby-engine instead of Docker.

Docker has been removed from Fedora 31, replaced by moby-engine (Although neither supports cgroups v2). If you are not familiar with Moby and its relationship with Docker, it is recommended to read This article.
Install moby-engine (Including Docker CLI and Docker Engine) On Fedora 31, enable and start its daemon, use:

sudo dnf install moby-engine

sudo systemctl enable --now docker

You may also want to add users to docker Group, so you don’t have to run it with superuser privileges:

sudo usermod -aG docker $(whoami)

After that you need to restart the system to use moby-engine No superuser privileges (e.g. sudo).
You can now use moby-engine For example, Docker, for example:

docker run --rm hello-world:latest

You might also like: LazyDocker: New Docker and Docker Compose Terminal UI

Please show me how to install Docker CE on Fedora 31.

Like moby-engineDocker Engine-Community does not support cgroup v2, so before proceeding, follow the instructions above to switch to cgroup v1.
If you want to install using Docker CE, delete moby-engine If you previously installed it:

sudo dnf remove moby-engine

Now you can add the Docker CE Fedora repository, install Docker CE (this will also install docker-ce-cli with containerd.io), Enable and start its daemon:

sudo dnf config-manager --add-repo https://download.docker.com/linux/fedora/docker-ce.repo

sudo dnf install docker-ce

sudo systemctl enable --now docker

You may also want to add users to docker Group, so you don’t have to run Docker with superuser privileges:

sudo usermod -aG docker $(whoami)

After that, you need to restart your system to use Docker without superuser privileges (for example, sudo).
Extra resources (in addition to the resources linked in the article):

Source

Sidebar