How To Install Docker On Fedora 31 (And Alternatives)

Fedora logo

Fedora 31 switched to cgroup v2, being the first major Linux distribution to do so. Docker doesn't support cgroup v2 though, so it doesn't work on the latest Fedora release. This article explains your options, and how to install Docker on Fedora 31 if you don't like the alternatives.

cgroup (control group) is a Linux kernel feature that organizes processes hierarchically and distributes system resources along the hierarchy in a controlled and configurable manner. cgroup v2 first appeared in Linux kernel 4.5, and unlike v1, it only has a single process hierarchy and discriminates between processes, not threads. I recommend reading this article on Fedora 31 and control group v2.

Since Fedora 31 switched to cgroups v2, Docker no longer works. For example, this error pops up on my Fedora 31 system when trying to run a container using Docker:

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 what can you do now that Fedora 31 uses cgroups v2, and Docker no longer works? You'll find some options below, including a workaround for installing Docker CE. As usual, all instructions were tested before posting them on Linux Uprising.

Option #1: Use Podman instead of Docker on Fedora 31


Pod Manager tool (podman) is a RedHat-backed cgroup v2-compatible container engine that implements almost all the Docker CLI commands, and doesn't require a daemon to run containers and pods. This is the Fedora recommended option.

Podman is installed by default on Fedora 31 so there's nothing you need to do to use it. Just run podman instead of 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.


Besides using Podman (option #1), you have the option of switching your Fedora 31 system to cgroup v1, by passing the kernel parameter systemd.unified_cgroup_hierarchy=0.

This can be done (permanently) from the command line as follows:

sudo dnf install grubby

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

After this, reboot your system and you'll now have the option of using either moby-engine (includes Docker CLI and the Docker Engine) or Docker CE.

In case you want to undo this change this later, pass the kernel parameter systemd.unified_cgroup_hierarchy without an argument or with true as an argument. This re-enables the usage of unified cgroup hierarchy (cgroup v2), e.g.:

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

Use moby-engine instead of Docker.


Docker has been removed from Fedora 31, being replaced by moby-engine (both don't yet support cgroups v2 though). In case you're not familiar with Moby and its relationship with Docker, I recommend reading this article.

To install moby-engine (includes Docker CLI and the 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 your user to the docker group so you don't have to run it with super user privileges:

sudo usermod -aG docker $(whoami)

After this you'll need to reboot your system in order to use moby-engine without super user privileges (e.g. sudo).

You can now use moby-engine like Docker, e.g.:

docker run --rm hello-world:latest

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

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


Like moby-engine, Docker Engine - Community doesn't support cgroup v2, so switch to cgroup v1 as explained above before proceeding.

If you want to install use Docker CE, remove moby-engine in case you installed it previously:

sudo dnf remove moby-engine

Now you can add the Docker CE Fedora repository, install Docker CE (this will also install docker-ce-cli and 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 your user to the docker group so you don't have to run Docker with super user privileges:

sudo usermod -aG docker $(whoami)

After this you'll need to reboot your system in order to use Docker without super user privileges (e.g. sudo).

Extra sources (besides the ones already linked in the article):