Docker gives you the option of installing it in several ways. Choosing from Docker's repositories, RPM packages, and convenience scripts. The official Docker documentation describes all those options up to Fedora's version 31. But for version 32 there are none. This guide describes step-by-step, how to install Docker Compose on Fedora 32. Including all encountered errors and how to correct them.

Table of Contents:

  1. Installing Docker from convenience script
    1.1 Cannot download repodata
    1.2 Clean up the script
    1.3 Find the faulty repo
    1.4 Check if the update completes without errors
  2. Install Docker from DNF
  3. Install Docker Compose
    3.1 Create a Docker Compose File
    3.2 Building the Docker Images
    3.3 No connection between the containers
    3.4 Configure Firewalld
  4. Take me to the solution
  5. Or run this script for convenience

Installing Docker from convenience script

Get the Docker script from the official Docker site by running curl from your terminal.

[dev@web ~]$ curl -fsSL https://get.docker.com -o get-docker.sh

Now run the script with elevated privileges.

[dev@web ~]$ sudo sh get-docker.sh
[sudo] password for dev:
# Executing docker install script, commit: 26ff363bcf3b3f5a00498ac43694bf1c7d9ce16c
+ sh -c 'dnf install -y -q dnf-plugins-core'
+ sh -c 'dnf config-manager --add-repo https://download.docker.com/linux/fedora/docker-ce.repo'
Adding repo from: https://download.docker.com/linux/fedora/docker-ce.repo
+ '[' stable '!=' stable ']'
+ sh -c 'dnf makecache'
Docker CE Stable - x86_64                                                                                                                                                                                     1.1 kB/s | 577  B     00:00
Errors during downloading metadata for repository 'docker-ce-stable':
  - Status code: 404 for https://download.docker.com/linux/fedora/32/x86_64/stable/repodata/repomd.xml (IP: 13.227.223.3)
Error: Failed to download metadata for repo 'docker-ce-stable': Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried
Fedora 32 openh264 (From Cisco) - x86_64                                                                                                                                                                      2.9 kB/s | 986  B     00:00
Fedora Modular 32 - x86_64                                                                                                                                                                                     56 kB/s |  24 kB     00:00
Fedora Modular 32 - x86_64 - Updates                                                                                                                                                                           44 kB/s |  19 kB     00:00
Fedora Modular 32 - x86_64 - Updates                                                                                                                                                                           80 kB/s |  59 kB     00:00
Fedora 32 - x86_64 - Updates                                                                                                                                                                                   47 kB/s |  21 kB     00:00
Fedora 32 - x86_64                                                                                                                                                                                             57 kB/s |  24 kB     00:00
Ignoring repositories: docker-ce-stable
Metadata cache created.
+ '[' -n '' ']'
+ sh -c 'dnf install -y -q docker-ce'
Error: Unable to find a match: docker-ce

As you can see in the marked lines the script fails with the following error messages:

  • Errors during downloading metadata for repository 'docker-ce-stable':
  • Status code: 404 for https://download.docker.com/linux/fedora/32/x86_64/stable/repodata/repomd.xml
  • Error: Failed to download metadata for repo 'docker-ce-stable': Cannot download repomd.xml

Let’s take a closer look at why this happens.

Cannot download repodata

The 404 error message seems to be correct when you open up the URL from a web browser.

Parent folder repodata is missing as well. This continues to be the case up to the index of linux/fedora = https://download.docker.com/linux/fedora. Where it becomes clear that the 32 repository doesn't even exist.

While reading through official Docker documentation on installing Docker using the convenience script. There is no mention of Fedora 32 in the OS requirements either.

Clean up the script

Since the installation failed let's clean-up the cached packages and repository data.

[dev@web ~]$ sudo dnf clean all
[sudo] password for dev:
41 files removed

This doesn't seem to fix the issue when you run dnf update again. The error still persists.

[dev@web ~]$ sudo dnf update
Docker CE Stable - x86_64                                                                                                                                                                                     1.0 kB/s | 577  B     00:00
Errors during downloading metadata for repository 'docker-ce-stable':
  - Status code: 404 for https://download.docker.com/linux/fedora/32/x86_64/stable/repodata/repomd.xml (IP: 13.227.223.127)
Error: Failed to download metadata for repo 'docker-ce-stable': Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried
Ignoring repositories: docker-ce-stable
Last metadata expiration check: 
Dependencies resolved.
Nothing to do.
Complete!

The error message persists even after removing the contents of the cache directory.

[dev@web ~]$ sudo rm -r /var/cache/dnf

Let’s think for a moment. The error message states that it can’t find the metadata from the repository added by the script. So, let’s go find and remove this repository.

Find the faulty repo

List all the repositories by running the following command:

[dev@web ~]$ sudo ls -l /etc/yum.repos.d
total 32
-rw-r--r--. 1 root root 2544 May 20 16:55 docker-ce.repo
-rw-r--r--. 1 root root  728 Apr 13 16:22 fedora-cisco-openh264.repo
-rw-r--r--. 1 root root 1303 Apr 13 16:22 fedora-modular.repo
-rw-r--r--. 1 root root 1239 Apr 13 16:22 fedora.repo
-rw-r--r--. 1 root root 1349 Apr 13 16:22 fedora-updates-modular.repo
-rw-r--r--. 1 root root 1286 Apr 13 16:22 fedora-updates.repo
-rw-r--r--. 1 root root 1391 Apr 13 16:22 fedora-updates-testing-modular.repo
-rw-r--r--. 1 root root 1344 Apr 13 16:22 fedora-updates-testing.repo

The highlighted repository is the one we're looking for. Now remove it by running the following command.

[dev@web ~]$ sudo rm /etc/yum.repos.d/docker-ce.repo

Check if the update completes without errors

Update again to check if this solved our issue by running the following command:

[dev@web ~]$ sudo dnf update
Fedora Modular 32 - x86_64 - Updates                                                                                                                                                                          1.3 MB/s | 1.7 MB     00:01
Fedora 32 - x86_64 - Updates                                                                                                                                                                                  4.9 MB/s |  11 MB     00:02
Fedora 32 - x86_64                                                                                                                                                                                            6.7 MB/s |  70 MB     00:10
Last metadata expiration check: 
Dependencies resolved.
Nothing to do.
Complete!

Update completed without any error messages. Now we can finally get started with getting Docker to work on Fedora 32.

Install Docker from DNF

Another method that seems to do the trick is to install Docker from dnf by running the following command:

[dev@web ~]$ sudo dnf install docker -y
[sudo] password for dev:
Last metadata expiration check: 
Dependencies resolved.
==============================================================================================================================================================================================================================================
 Package                                                     Architecture                                     Version                                                                 Repository                                         Size
==============================================================================================================================================================================================================================================
Installing:
 moby-engine                                                 x86_64                                           19.03.8-1.ce.gitafacb8b.fc32                                            fedora                                             51 M
Installing dependencies:
 container-selinux                                           noarch                                           2:2.132.0-1.fc32                                                        updates                                            48 k
 containerd                                                  x86_64                                           1.3.3-1.fc32                                                            updates                                            32 M

Transaction Summary
==============================================================================================================================================================================================================================================
Install  3 Packages

Total download size: 83 M
Installed size: 303 M
Downloading Packages:
(1/3): container-selinux-2.132.0-1.fc32.noarch.rpm                                                                                                                                                             86 kB/s |  48 kB     00:00
(2/3): moby-engine-19.03.8-1.ce.gitafacb8b.fc32.x86_64.rpm                                                                                                                                                    5.9 MB/s |  51 MB     00:08
(3/3): containerd-1.3.3-1.fc32.x86_64.rpm                                                                                                                                                                     3.0 MB/s |  32 MB     00:10
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                                                                         7.0 MB/s |  83 MB     00:11
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                                                                                                      1/1
  Installing       : containerd-1.3.3-1.fc32.x86_64                                                                                                                                                                                       1/3
  Running scriptlet: containerd-1.3.3-1.fc32.x86_64                                                                                                                                                                                       1/3
  Running scriptlet: container-selinux-2:2.132.0-1.fc32.noarch                                                                                                                                                                            2/3
  Installing       : container-selinux-2:2.132.0-1.fc32.noarch                                                                                                                                                                            2/3
  Running scriptlet: container-selinux-2:2.132.0-1.fc32.noarch                                                                                                                                                                            2/3
  Running scriptlet: moby-engine-19.03.8-1.ce.gitafacb8b.fc32.x86_64                                                                                                                                                                      3/3
  Installing       : moby-engine-19.03.8-1.ce.gitafacb8b.fc32.x86_64                                                                                                                                                                      3/3
  Running scriptlet: moby-engine-19.03.8-1.ce.gitafacb8b.fc32.x86_64                                                                                                                                                                      3/3
Created symlink /etc/systemd/system/sockets.target.wants/docker.socket → /usr/lib/systemd/system/docker.socket.

  Running scriptlet: container-selinux-2:2.132.0-1.fc32.noarch                                                                                                                                                                            3/3
  Running scriptlet: moby-engine-19.03.8-1.ce.gitafacb8b.fc32.x86_64                                                                                                                                                                      3/3
  Verifying        : container-selinux-2:2.132.0-1.fc32.noarch                                                                                                                                                                            1/3
  Verifying        : containerd-1.3.3-1.fc32.x86_64                                                                                                                                                                                       2/3
  Verifying        : moby-engine-19.03.8-1.ce.gitafacb8b.fc32.x86_64                                                                                                                                                                      3/3

Installed:
  container-selinux-2:2.132.0-1.fc32.noarch                                       containerd-1.3.3-1.fc32.x86_64                                       moby-engine-19.03.8-1.ce.gitafacb8b.fc32.x86_64

Complete!

The installation completed without any error messages. Confirm the installation of Docker by running the following command:

[dev@web ~]$ docker --version
Docker version 19.03.8, build afacb8b

Add your user to the Docker group if you don't want to run the Docker commands as a sudo user all the time.

[dev@web ~]$ sudo usermod -aG docker change_to_your_user_name

Enable the Docker service to run on boot.

[dev@web ~]$ sudo systemctl enable docker.service
Created symlink /etc/systemd/system/multi-user.target.wants/docker.service → /usr/lib/systemd/system/docker.service

Start the Docker service.

[dev@web ~]$ sudo systemctl start docker.service

Install Docker Compose

After installing Docker it's time to install Compose as well. At the moment of writing the current stable release is 1.25.5. You can always check for the latest version on Docker or Github.

[dev@web ~]$ sudo curl -L "https://github.com/docker/compose/releases/download/1.25.5/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
[sudo] password for dev:
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   638  100   638    0     0   6934      0 --:--:-- --:--:-- --:--:--  6860
100 16.7M  100 16.7M    0     0  5696k      0  0:00:03  0:00:03 --:--:-- 8200k

Apply executable permissions to the binary by running the following command:

[dev@web ~]$ sudo chmod +x /usr/local/bin/docker-compose

No error messages here as well. Confirm the installation of Docker Compose by running the following command:

[dev@web ~]$ docker-compose --version
docker-compose version 1.25.5, build 8a1c60f6

Create a Docker Compose File

Now, let's create a directory and a configuration file for our Docker Compose setup.

[dev@web ~]$ sudo mkdir /opt/docker

The configuration file will consist of the official WordPress and MySQL configuration. Use your editor of choice or copy and paste the code from below to your terminal.

[dev@web ~]$ sudo bash -c "cat <<EOT >>/opt/docker/docker-compose.yml                  
version: '3.3'
 
services:
   db:
     image: mysql:5.7
     volumes:
       - db_data:/var/lib/mysql
     restart: always
     environment:
       MYSQL_ROOT_PASSWORD: somewordpress
       MYSQL_DATABASE: wordpress
       MYSQL_USER: wordpress
       MYSQL_PASSWORD: wordpress
 
   wordpress:
     depends_on:
       - db
     image: wordpress:latest
     ports:
       - "8000:80"
     restart: always
     environment:
       WORDPRESS_DB_HOST: db:3306
       WORDPRESS_DB_USER: wordpress
       WORDPRESS_DB_PASSWORD: wordpress
       WORDPRESS_DB_NAME: wordpress
volumes:
    db_data: {}
EOT
"

Building the Docker Images

Now that Docker and Compose are both installed. Let's build our images by running the docker-compose file.

The system wasn't restarted up to this point for the new permissions to become active. Run the Docker-Compose file with sudo permissions for now.

[dev@web ~]$ sudo docker-compose -f /opt/docker/docker-compose.yml up -d
Creating network "docker_default" with the default driver
Creating volume "docker_db_data" with default driver
Pulling db (mysql:5.7)...
5.7: Pulling from library/mysql
afb6ec6fdc1c: Pull complete
0bdc5971ba40: Pull complete
97ae94a2c729: Pull complete
f777521d340e: Pull complete
1393ff7fc871: Pull complete
a499b89994d9: Pull complete
7ebe8eefbafe: Pull complete
4eec965ae405: Pull complete
a531a782d709: Pull complete
10e94c02b508: Pull complete
799a94b968ef: Pull complete
Digest: sha256:5c9fd7949bc0f076429fa2c40d0e7406e095bdb5216a923257b31972a6f3ae4f
Status: Downloaded newer image for mysql:5.7
Pulling wordpress (wordpress:latest)...
latest: Pulling from library/wordpress
afb6ec6fdc1c: Already exists
3d895574014b: Pull complete
c309fdad6410: Pull complete
c201f6a5d6f9: Pull complete
e87f853892aa: Pull complete
998b2113b400: Pull complete
b3c0b4710d3b: Pull complete
c79fb2b38801: Pull complete
30aa6f0dd423: Pull complete
8af9a337c36d: Pull complete
64ec85e06910: Pull complete
606f88b4f608: Pull complete
845e768a44c5: Pull complete
232824f4bf64: Pull complete
c14e31cd46f2: Pull complete
df59d99840f5: Pull complete
0f3a9380af13: Pull complete
348bafbbcb22: Pull complete
d96f27aa3b63: Pull complete
58f35ab6fddc: Pull complete
0c1a0d01788e: Pull complete
Digest: sha256:0b452b7b45fa770f12e864720abb01bef506f4abe273669402434e94323c97d7
Status: Downloaded newer image for wordpress:latest
Creating docker_db_1 ... error

ERROR: for docker_db_1  Cannot start service db: OCI runtime create failed: this version of runc doesn't work on cgroups v2: unknown

ERROR: for db  Cannot start service db: OCI runtime create failed: this version of runc doesn't work on cgroups v2: unknown
ERROR: Encountered errors while bringing up the project.

The Docker-Compose script fails with the highlighted above error messages:

After extensive application of Google-foo. The answer has presented itself in the following form.

To overcome this you'd have to switch the system to using cgroups v1 by running the following command:

[dev@web ~]$ sudo grubby --update-kernel=ALL --args="systemd.unified_cgroup_hierarchy=0"

Reboot the system after updating the kernel.

Running the Docker-Compose script after the reboot should finish building the images.

[dev@web ~]$ docker-compose -f /opt/docker/docker-compose.yml up -d
Starting docker_db_1 ... done
Creating docker_wordpress_1 ... done

No connection between the containers

The last thing which remains now is starting up Wordpress on the port configured in the YAML file.

It looks like Wordpress is running. But it's not able to communicate with the database. Which results in: 'Error establishing a database connection'.

Running apt update from the container itself only confirms the lack of connectivity.

root@564a34e5514b:/var/www/html# apt update
Err:1 http://deb.debian.org/debian buster InRelease                  
  Temporary failure resolving 'deb.debian.org'
Err:2 http://security.debian.org/debian-security buster/updates InRelease
  Temporary failure resolving 'security.debian.org'
Err:3 http://deb.debian.org/debian buster-updates InRelease          
  Temporary failure resolving 'deb.debian.org'
Reading package lists... Done    
Building dependency tree       
Reading state information... Done
All packages are up to date.
W: Failed to fetch http://deb.debian.org/debian/dists/buster/InRelease  Temporary failure resolving 'deb.debian.org'
W: Failed to fetch http://security.debian.org/debian-security/dists/buster/updates/InRelease  Temporary failure resolving 'security.debian.org'
W: Failed to fetch http://deb.debian.org/debian/dists/buster-updates/InRelease  Temporary failure resolving 'deb.debian.org'
W: Some index files failed to download. They have been ignored, or old ones used instead.

As mentioned in this GitHub post. The networking issues are due to firewalld switching from iptables to nftables.

Configure Firewalld

By running sudo ls -l on the /etc/firewalld directory. We can actually see that firewalld.conf is a symbolic link. Pointing to firewalld-workstation.conf.

[dev@web ~]$ sudo ls -l /etc/firewalld
[sudo] password for dev:
total 36
lrwxrwxrwx. 1 root root   26 Apr 23 00:38 firewalld.conf -&gt; firewalld-workstation.conf
-rw-r--r--. 1 root root 2751 May 13 18:16 firewalld-server.conf
-rw-r--r--. 1 root root 2745 May 13 18:16 firewalld-standard.conf
-rw-r--r--. 1 root root 2756 May 13 18:16 firewalld-workstation.conf
drwxr-x---. 2 root root 4096 May 13 18:16 helpers
drwxr-x---. 2 root root 4096 May 13 18:16 icmptypes
drwxr-x---. 2 root root 4096 May 13 18:16 ipsets
-rw-r--r--. 1 root root  271 May 13 18:16 lockdown-whitelist.xml
drwxr-x---. 2 root root 4096 May 13 18:16 services
drwxr-x---. 2 root root 4096 May 13 18:16 zones

You can set the value of the config file to iptables by running the following command:

[dev@web ~]$ sudo sed -i 's/FirewallBackend=nftables/FirewallBackend=iptables/g' /etc/firewalld/firewalld-workstation.conf

Or look for the following line 'FirewallBackend=nftables' with your editor of choice. Replace it with 'FirewallBackend=iptables'.

Restart the firewalld.service so you don't have to reboot the system again.

[dev@web ~]$ sudo systemctl restart firewalld.service

You are now presented with the WordPress installer when you open up WordPress again.

The WordPress container is now also able to run the apt update.

root@564a34e5514b:/var/www/html# apt update
Get:1 http://deb.debian.org/debian buster InRelease [121 kB]
Get:2 http://security.debian.org/debian-security buster/updates InRelease [65.4 kB]
Get:3 http://deb.debian.org/debian buster-updates InRelease [49.3 kB]
Get:4 http://deb.debian.org/debian buster/main amd64 Packages [7905 kB]
Get:5 http://security.debian.org/debian-security buster/updates/main amd64 Packages [201 kB]
Get:6 http://deb.debian.org/debian buster-updates/main amd64 Packages [7380 B]
Fetched 8350 kB in 2s (3667 kB/s)                    
Reading package lists... Done
Building dependency tree       
Reading state information... Done
All packages are up to date.

Take me to the solution

If you only need the solution follow these steps.

[dev@web ~]$ sudo dnf install docker -y
[dev@web ~]$ sudo usermod -aG docker change_to_your_user_name
[dev@web ~]$ sudo systemctl enable docker.service
[dev@web ~]$ sudo curl -L "https://github.com/docker/compose/releases/download/1.25.5/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
[dev@web ~]$ sudo chmod +x /usr/local/bin/docker-compose
[dev@web ~]$ sudo mkdir /opt/docker
[dev@web ~]$ sudo bash -c "cat <<EOT >>/opt/docker/docker-compose.yml                  
version: '3.3'
 
services:
   db:
     image: mysql:5.7
     volumes:
       - db_data:/var/lib/mysql
     restart: always
     environment:
       MYSQL_ROOT_PASSWORD: somewordpress
       MYSQL_DATABASE: wordpress
       MYSQL_USER: wordpress
       MYSQL_PASSWORD: wordpress
 
   wordpress:
     depends_on:
       - db
     image: wordpress:latest
     ports:
       - "8000:80"
     restart: always
     environment:
       WORDPRESS_DB_HOST: db:3306
       WORDPRESS_DB_USER: wordpress
       WORDPRESS_DB_PASSWORD: wordpress
       WORDPRESS_DB_NAME: wordpress
volumes:
    db_data: {}
EOT
"
[dev@web ~]$ sudo grubby --update-kernel=ALL --args="systemd.unified_cgroup_hierarchy=0"
[dev@web ~]$ sudo sed -i 's/FirewallBackend=nftables/FirewallBackend=iptables/g' /etc/firewalld/firewalld-workstation.conf
[dev@web ~]$ sudo reboot
[dev@web ~]$ docker-compose -f /opt/docker/docker-compose.yml up -d

Or run this script for convenience

For convenience, the following script takes care of all the steps written in our guide. Save it as a shell file and run it from your terminal with elevated privileges. A quick preview on how it works.

#!/bin/bash
# Install Docker-Compose & Wordpress on Fedora 32
# created by: TechGuideReview
set -x # echo on

### install docker from dnf ###
dnf install docker -y

### create docker user group ###
groupadd docker

### add run permissions to the current user ###
usermod -aG docker $SUDO_USER

### run docker service on boot ###
systemctl enable docker.service

### get docker compose ###
curl -L "https://github.com/docker/compose/releases/download/1.25.5/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

### apply permissions docker compose ###
chmod +x /usr/local/bin/docker-compose

### create directory in Documents for the compose file ###
mkdir /opt/docker

### populate docker compose file ###
echo "version: '3.3'

services:
   db:
     image: mysql:5.7
     volumes:
       - db_data:/var/lib/mysql
     restart: always
     environment:
       MYSQL_ROOT_PASSWORD: somewordpress
       MYSQL_DATABASE: wordpress
       MYSQL_USER: wordpress
       MYSQL_PASSWORD: wordpress

   wordpress:
     depends_on:
       - db
     image: wordpress:latest
     ports:
       - "8000:80"
     restart: always
     environment:
       WORDPRESS_DB_HOST: db:3306
       WORDPRESS_DB_USER: wordpress
       WORDPRESS_DB_PASSWORD: wordpress
       WORDPRESS_DB_NAME: wordpress
volumes:
    db_data: {}
" > /opt/docker/docker-compose.yml

### apply kernel mod ###
grubby --update-kernel=ALL --args="systemd.unified_cgroup_hierarchy=0"

### change firewalld to iptables ###
sed -i 's/FirewallBackend=nftables/FirewallBackend=iptables/g' /etc/firewalld/firewalld-workstation.conf

Reboot your system after running the script. Then run the Docker-Compose script from the terminal by running: docker-compose -f /opt/docker/docker-compose.yml up -d

If you stayed with us up to this point, then you already know how to install Docker Compose on Fedora 32. If you also would like to know how to increase the maximal upload size of WordPress in Docker you can read it over here.