Installing Docker Engine on Fedora: Handling Podman Conflicts and Network Errors

Fedora tutorial - IT technology blog
Fedora tutorial - IT technology blog

Quick Setup: Install Docker Engine in 5 Minutes

If you just need Docker running right away, copy-paste the commands below. I’ve stripped away the fluff so you can get a standard container environment immediately.

# 1. Clean up old versions or conflicting packages
sudo dnf remove docker \
                  docker-client \
                  docker-client-latest \
                  docker-common \
                  docker-latest \
                  docker-latest-logrotate \
                  docker-logrotate \
                  docker-selinux \
                  docker-engine-selinux \
                  docker-engine

# 2. Set up the official repository
sudo dnf -y install dnf-plugins-core
sudo dnf config-manager --add-repo https://download.docker.com/linux/fedora/docker-ce.repo

# 3. Install Docker Engine and plugins
sudo dnf install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

# 4. Enable the service
sudo systemctl enable --now docker

# 5. Run Docker without sudo (saves typing time)
sudo usermod -aG docker $USER
newgrp docker

Check your results with: docker run hello-world. If you see “Hello from Docker!”, you’re good to go.

Why does installing Docker on Fedora often lead to errors?

I’ve used Fedora as my primary dev machine for over 2 years. The reality is that Fedora (and the Red Hat ecosystem) heavily favors Podman. It’s a daemonless, more secure container tool that comes pre-installed by default.

Many newcomers to Fedora get confused when typing docker and seeing a suggestion to install podman-docker. This is actually just an alias (a “fake” version). While Podman is powerful, many CI/CD scripts or complex projects still require the real Docker Engine for 100% compatibility.

The biggest hurdles when installing Docker on Fedora are cgroup v2 and Firewalld. These are the two main culprits causing your containers to fail to start or lose network connectivity.

Troubleshooting “Painful” Technical Issues

1. cgroup v2 Error: When old Docker doesn’t understand Fedora

Fedora pioneered cgroup v2 since version 31. Previously, older Docker versions often threw the error failed to create shim task due to incompatibility. Modern Docker CE versions (20.10+) now support cgroup v2 natively, so you no longer need to downgrade to v1 as suggested by outdated tutorials.

2. No Network in Containers (Firewalld Error)

This is a classic: the container starts, but you can’t run apt update or ping the outside world. This happens because firewalld blocks connections from the Docker bridge. To fix this, add Docker to the trusted zone:

# Allow Docker masquerade for internet access
sudo firewall-cmd --permanent --zone=public --add-masquerade
sudo firewall-cmd --reload
sudo systemctl restart docker

After reloading, try docker run --rm alpine ping google.com to confirm connectivity.

Running Docker and Podman Side-by-Side: Critical Notes

You can definitely install both, but don’t let them clash. Here are 3 rules I’ve learned:

  • Separate Image Stores: Docker images are in /var/lib/docker, while Podman stores them elsewhere. Pulling on one side won’t make it visible on the other.
  • Port Conflicts: If Podman is already using port 80 for Nginx, Docker will throw a Bind for 0.0.0.0:80 failed error. Remember to check podman ps before running Docker.
  • Avoid Aliases: Never install podman-docker. It overwrites the docker command and will drive you crazy when debugging system errors.

How to check for “The Real Deal”:

which docker
# The correct result should be /usr/bin/docker. If it points to /usr/bin/podman, you're using the "fake" version.

Optimization Tips for Developers

Use the latest Docker Compose V2

Forget the old <a href="https://itfromzero.com/en/linux-vi-en/fedora-vi-en-linux-vi-en/using-podman-compose-on-fedora-replacing-docker-compose-for-rootless-multi-container-application-management.html">docker-compose</a> written in Python. With the docker-compose-plugin installed above, use the new syntax: docker compose up -d (no hyphen). The build speed and resource management of V2 are significantly better.

Configure Logs to Save Disk Space

Dev laptops often have limited SSD space. Docker defaults to infinite logs, which can take up dozens of GBs over time. Limit this by editing /etc/docker/daemon.json:

{
  "log-driver": "json-file",
  "log-opts": {
    "max-size": "10m",
    "max-file": "3"
  }
}

Then restart: sudo systemctl restart docker. Now each container will only take up a maximum of 30MB of logs—very lightweight.

Conclusion

Installing Docker on Fedora isn’t hard; the key is understanding how it coexists with Firewalld and SELinux. Never disable SELinux (setenforce 0) just to run Docker. Instead, use the :Z flag when mounting volumes to ensure proper Fedora security standards.

Share: