Linux System AdministrationLinux Troubleshooting GuideLinux Tutorials

How to Install and Configure Docker on Fedora Linux for Optimal Container Management

Docker is a powerful and widely-used containerization platform that simplifies application deployment and management. While Fedora Linux ships with Podman as its default container runtime, many developers and enterprises prefer Docker due to its extensive ecosystem, compatibility with various CI/CD pipelines, and robust tooling. In this comprehensive guide, we will walk you through step-by-step instructions on installing Docker on Fedora Linux, configuring it for non-root users, managing firewall settings, and troubleshooting common issues. This tutorial covers both the official Docker CE installation and Fedora’s Moby Engine alternative, ensuring you choose the best solution for your environment with full systemd integration and security best practices.

Docker Installation Methods on Fedora Linux

Fedora users can install Docker using two main approaches, each suited for different needs and preferences:

  • Docker CE (Community Edition): This is the official Docker release directly provided by Docker Inc. Users get the latest stable features, official Docker Compose, Buildx plugins, and timely updates from Docker’s repositories.
  • Moby Engine: An open-source upstream container engine maintained by Fedora. It is available out-of-the-box via Fedora’s default package repositories, offering an easier setup without requiring third-party repos.

While Docker CE is recommended for users seeking cutting-edge functionality and official support, Moby Engine provides a native Fedora experience aligned with distribution updates. This guide demonstrates installation, configuration, and management for both methods.

Installing Docker CE on Fedora from Official Docker Repository

To leverage the latest Docker functionality on Fedora, follow these steps to install Docker CE from Docker’s official repository.

1. Remove Older Docker Versions

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

Warning: No packages marked for removal

This command removes any previously installed Docker versions to avoid conflicts during the new installation. The message indicates whether such packages were present.

2. Update Fedora System

sudo dnf upgrade --refresh

Dependencies resolved.
...
Complete!

Running this ensures your system packages and metadata are up to date before installing new software.

3. Verify dnf Plugin Availability

dnf config-manager --help | head -5

Usage: dnf [GLOBAL OPTIONS] config-manager  ... Description: Manage main and repositories configuration...

Check that the config-manager tool is available for managing repositories. Install dnf5-plugins if necessary.

4. Add Docker CE Repository

sudo dnf config-manager addrepo --from-repofile=https://download.docker.com/linux/fedora/docker-ce.repo

Repository 'docker-ce' successfully added

This adds the official Docker CE repo to your Fedora system.

5. Install Docker CE Packages

sudo dnf install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

Installed:
 docker-ce.x86_64 29.x.x-1.fc43
 docker-ce-cli.x86_64 29.x.x-1.fc43
 containerd.io.x86_64 1.8.x
 docker-buildx-plugin.x86_64 0.11.x
 docker-compose-plugin.x86_64 2.x

This command installs the Docker daemon, CLI client, container runtime, and essential plugins including Docker Compose and Buildx.

6. Verify Installation

docker --version

Docker version 29.x.x, build xxxxxxx

docker compose version

Docker Compose version v5.x.x

Confirm Docker and Docker Compose are correctly installed and accessible.

Installing Moby Engine on Fedora via Default Repositories

If you prefer using packages maintained within Fedora repos without adding third-party sources, Moby Engine is an excellent alternative.

1. Install Moby Engine and Docker Compose

sudo dnf install moby-engine docker-compose

Installed:
 moby-engine.x86_64 29.x.x.fc43
 docker-compose.x86_64 5.x.x

Moby Engine provides a Docker-compatible daemon; the docker-compose package here also supports both docker compose and docker-compose commands.

2. Verify Installation

docker --version

Docker version 29.x.x, build x.fc43

docker-compose --version

Docker Compose version 5.x.x

Check that Moby Engine and Compose are correctly installed.

Starting and Enabling Docker Service on Fedora

Docker does not start automatically upon installation, so you must enable and start the service manually.

Enable Docker to Start on Boot and Start it Immediately

sudo systemctl enable docker --now

Created symlink /etc/systemd/system/multi-user.target.wants/docker.service → /usr/lib/systemd/system/docker.service.

The –now flag starts the Docker service immediately along with enabling it on system startup.

Check Docker Service Status

sudo systemctl status docker

● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
   Active: active (running) since Tue 2026-03-03 09:14:36 UTC; 5s ago
     Docs: https://docs.docker.com
 Main PID: 1234 (dockerd)
    Tasks: 8
   Memory: 55.0M
   CGroup: /system.slice/docker.service
           └─1234 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock

This output confirms Docker daemon is active and running.

Test Docker with Hello World Container

docker run hello-world

Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
Digest: sha256:ef54e8...
Status: Downloaded newer image for hello-world:latest
Hello from Docker!
This message shows that your installation appears to be working correctly.

Running this container verifies Docker can pull images and execute containers successfully.

Configuring Docker for Non-Root User Usage

By default, Docker commands require superuser privileges. To avoid using sudo every time, add your user to the docker group.

Add Your User to the Docker Group

sudo usermod -aG docker $USER

This command appends the current user to the docker group. You must log out and back in or reboot to apply the group membership.

Verify Docker Commands Without Sudo

docker ps

CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES

If this command returns without permission errors and shows running containers (if any), Docker is accessible without sudo.

Configuring Docker Logging on Fedora

Docker allows configuring different logging drivers for container logs. Fedora’s Docker CE defaults to json-file, whereas Moby Engine uses journald. You can customize logging by editing /etc/docker/daemon.json.

Create or Edit Daemon Configuration

sudo nano /etc/docker/daemon.json

{
  "log-driver": "syslog",
  "log-opts": {
    "syslog-address": "tcp://logs.example.com:514",
    "syslog-facility": "daemon",
    "tag": "{{.Name}}"
  }
}

This example configures Docker to forward logs to a remote syslog server. Replace logs.example.com with your syslog server address.

Apply Configuration and Restart Docker

sudo systemctl restart docker

Restart Docker for changes to take effect.

Verify Active Logging Driver

docker info --format '{{.LoggingDriver}}'

syslog

This confirms Docker is using the specified logging driver.

Managing Firewall Rules for Docker Containers

When exposing container ports externally, adjust Fedora’s firewall (firewalld) rules accordingly.

Allow Incoming TCP Port 8080

sudo firewall-cmd --permanent --add-port=8080/tcp
sudo firewall-cmd --reload

This opens port 8080 permanently and reloads the firewall to apply.

List Active Firewall Rules

sudo firewall-cmd --list-all

public (active)
  target: default
  icmp-block-inversion: no
  interfaces: enp1s0
  sources:
  services: dhcpv6-client ssh
  ports: 8080/tcp
  protocols:
  masquerade: no
  forward-ports:
  source-ports:
  icmp-blocks:
  rich rules:

The output shows open ports including the newly added 8080/tcp port.

Essential Docker Commands for Fedora Users

Master these commands to manage containers, images, and related resources efficiently.

Command Description
docker run Launch and start a new container from an image
docker ps List currently running containers
docker ps -a List all containers, including stopped ones
docker images Display downloaded Docker images
docker build Build an image from a Dockerfile
docker stop Stop a running container
docker rm Remove a stopped container
docker rmi Delete a Docker image
docker network Manage Docker networks
docker volume Manage Docker volumes

Run an Interactive Container Session

docker run -it ubuntu:latest /bin/bash

root@containerid:/#

This starts the official Ubuntu image with an interactive bash shell for direct container control.

Run a Detached Nginx Web Server Container

docker run -d --name webserver -p 8080:80 nginx

e3a1b6c7d89f0123456789abcdef0123456789abcdef0123456789abcdef0123

The command runs Nginx in the background, mapping port 8080 on the host to container port 80 for web access.

Troubleshooting Docker on Fedora

Permission Denied Errors When Running Non-Sudo Docker Commands

docker ps

docker: Got permission denied while trying to connect to the Docker daemon socket ... permission denied.

This indicates your user is not in the docker group. Add your user with sudo usermod -aG docker $USER and re-login.

Docker Service Fails to Start

sudo systemctl status docker

● docker.service - Docker Application Container Engine
   Loaded: loaded ...
   Active: failed (Result: exit-code) ...

Check service logs to identify the error:

sudo journalctl -xeu docker --no-pager | tail -20

Mar 3 10:15:33 dockerd[12345]: failed to start daemon: error reading config file: /etc/docker/daemon.json: invalid character

Common causes include syntax errors in daemon.json. Validate JSON syntax with appropriate tools and correct it before restarting.

SELinux Permission Denied on Bind Mounts

ls: cannot open directory '/data': Permission denied

Fedora SELinux often blocks container access to mounted host directories. Use the :Z or :z volume options to fix context issues:

docker run -v /home/user/data:/data:Z nginx

The :Z flag applies private SELinux labels suitable for single-container mounts, eliminating permission errors.

Podman Socket Conflicts

sudo systemctl status podman.socket

● podman.socket - Podman API Socket
   Loaded: loaded ...
   Active: active (listening) ...

If Podman’s socket conflicts with Docker, disable Podman’s socket and service to allow Docker to claim the socket:

sudo systemctl disable --now podman.socket
sudo systemctl disable --now podman.service

sudo systemctl restart docker

docker info | grep -i "server version"

Server Version: 29.x.x

Removing Docker from Fedora

To fully uninstall Docker and clean up resources, perform the following steps depending on your installation method.

Remove Docker CE

sudo systemctl stop docker
sudo dnf remove docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

Remove Docker CE packages and stop the Docker service.

Remove Official Docker Repository File

sudo rm /etc/yum.repos.d/docker-ce.repo

This cleans up the Docker repo configurations from your system.

Remove Moby Engine

sudo systemctl stop docker
sudo dnf remove moby-engine docker-compose

Uninstall the Moby Engine packages and stop the related service.

Clean Docker Data Directories

sudo rm -rf /var/lib/docker
sudo rm -rf /var/lib/containerd
sudo rm -rf /etc/docker

These commands remove all Docker images, containers, volumes, and configurations. Back up data if needed before executing.

Conclusion

Fedora Linux users can take advantage of Docker’s vast capabilities by choosing between Docker CE’s latest features or the Fedora-maintained Moby Engine. This guide has provided detailed, step-by-step instructions covering installation, service management, user permissions, logging, firewall configuration, and troubleshooting. By following these best practices, you can efficiently build, deploy, and manage containerized applications on Fedora servers or desktops with confidence and security. For further enhancements, consider integrating Docker workflows with Git version control and enabling secure remote management through SSH.

Leave a Reply

Your email address will not be published. Required fields are marked *