How To Install Docker on Fedora 42
Docker has revolutionized application deployment by enabling developers to package applications and their dependencies into portable containers. If you’ve recently upgraded to Fedora 42 or are setting up a new installation, you’ll want to get Docker running on your system efficiently. This comprehensive guide walks you through multiple methods to install Docker on Fedora 42, helping you choose the right approach for your needs while avoiding common pitfalls.
Understanding Docker on Fedora 42
Fedora 42 is the latest release in the Fedora Linux distribution family, and while Docker officially documents support for Fedora 40 and 41, the methods described here work perfectly on Fedora 42 as well. Docker offers several installation options for Fedora users, each with its own advantages.
Docker provides two main product variants that you should understand before proceeding:
Docker Engine is the open-source containerization technology that forms the foundation of the Docker platform. It’s ideal for developers and system administrators who need container functionality without a graphical interface.
Docker Desktop offers a more comprehensive experience with a GUI, simplified container management, and integrated tools. However, it requires a paid subscription for commercial use in enterprises with more than 250 employees or over $10 million in annual revenue.
System Requirements and Prerequisites for Docker on Fedora 42
Before installing Docker on Fedora 42, ensure your system meets these requirements:
- A 64-bit version of Fedora 42
- At least 4GB of RAM (8GB recommended for better performance)
- A processor with virtualization support enabled in BIOS/UEFI
- Sufficient storage space (at least 20GB free)
You should also remove any conflicting packages before proceeding with installation. This prevents potential conflicts and ensures a clean installation:
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
If none of these packages are installed, the command will simply report that no match was found, which is perfectly fine.
Method 1: Installing Docker Engine Using the RPM Repository
The recommended and most straightforward approach to installing Docker on Fedora 42 is using the official Docker repository. This method ensures you’ll receive updates and security patches directly from Docker.
Setting up the Docker Repository
First, install the required tools that will allow DNF to use the HTTPS-based Docker repository:
sudo dnf install dnf-plugins-core -y
Next, add the official Docker repository to your system’s repository list:
sudo dnf config-manager --add-repo https://download.docker.com/linux/fedora/docker-ce.repo
Installing Docker Engine Packages
With the repository configured, you can now install Docker Engine and its associated components:
sudo dnf install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
During installation, you might be prompted to accept a GPG key. Verify that the fingerprint matches 060A 61C5 1B55 8A7F 742B 77AA C52F EB6B 621E 9F35
before accepting it.
The installation process creates a docker
group on your system but doesn’t automatically add users to it yet. We’ll handle this in the post-installation section.
Installing a Specific Version of Docker Engine
If you need a specific version of Docker instead of the latest one, you can list all available versions and select one to install:
dnf list docker-ce --showduplicates | sort -r
This command outputs something like:
docker-ce.x86_64 3:28.1.1-1.fc41 docker-ce-stable
docker-ce.x86_64 3:28.1.0-1.fc41 docker-ce-stable
...
To install a specific version, use the package name followed by the version string:
sudo dnf install docker-ce-<VERSION> docker-ce-cli-<VERSION> containerd.io docker-buildx-plugin docker-compose-plugin
Replace <VERSION>
with your desired version string (e.g., 28.1.1-1.fc41
).
Starting and Enabling Docker Service
After installation, Docker is installed but not started. You need to start it manually and optionally configure it to launch at system boot:
sudo systemctl start docker
To automatically start Docker when your system boots:
sudo systemctl enable docker
Or combine both commands:
sudo systemctl enable --now docker
Verifying Your Docker Installation
Verify that Docker is working correctly by running the hello-world container:
sudo docker run hello-world
If everything is set up correctly, you should see a message indicating that your installation appears to be working correctly.
Check your Docker version:
docker --version
This should display something like:
Docker version 28.1.1, build 6312585
Method 2: Installing Docker Engine from Package Files
If you’re working in an air-gapped environment without internet access or need precise control over your installation, installing from package files might be the right approach.
When to Use This Method
This method is particularly useful for:
- Systems without internet access
- Environments where you need to audit packages before installation
- Scenarios requiring specific versions that might not be available in repositories
Downloading Docker RPM Packages
- Visit the official Docker package repository.
- Select the appropriate directory for Fedora 42 (or the closest available version)
- Navigate to the
x86_64/stable/Packages/
directory - Download the required RPM files for Docker Engine
You’ll need several packages including:
- docker-ce
- docker-ce-cli
- containerd.io
- docker-buildx-plugin
- docker-compose-plugin
Manual Installation Process
Once you’ve downloaded the packages, install them using DNF:
sudo dnf install /path/to/docker-ce.rpm /path/to/docker-ce-cli.rpm /path/to/containerd.io.rpm /path/to/docker-buildx-plugin.rpm /path/to/docker-compose-plugin.rpm
Replace the paths with the actual locations of your downloaded files.
Starting Docker and Verification
After installation, start and enable the Docker service:
sudo systemctl enable --now docker
Verify your installation by running the hello-world container:
sudo docker run hello-world
Method 3: Using the Docker Convenience Script
Docker provides a convenience script that automates the installation process. While this method is quick and straightforward, it’s generally not recommended for production environments.
Purpose and Limitations
The convenience script is designed for quick setup in development environments or for testing. However, it has several limitations:
- Less control over the installation process
- Potential security concerns from executing scripts directly from the internet
- May not be suitable for production environments requiring careful package management
Security Considerations
Before using any installation script downloaded from the internet, you should:
- Review the script content to understand what actions it will take
- Verify the script’s source and integrity
- Consider the implications of automatic updates and configuration changes
Installation Steps
- Download the installation script:
curl -fsSL https://get.docker.com -o get-docker.sh
- Make the script executable:
chmod u+x ./get-docker.sh
- Run the script with sudo privileges:
sudo sh ./get-docker.sh
The script will detect your OS, add the appropriate repositories, and install Docker and its dependencies.
Verification and Potential Issues
After installation, verify Docker is working correctly:
sudo docker run hello-world
Be aware that this method may cause issues with future upgrades or system package management. It’s generally better to use the repository method (Method 1) for long-term deployments.
Post-Installation Configuration
After installing Docker, several configuration steps can enhance your experience and security.
Running Docker Without Sudo
By default, Docker commands require sudo privileges. To run Docker commands as a non-root user, add your user to the docker group:
sudo usermod -aG docker $USER
For the changes to take effect, you’ll need to log out and back in. Alternatively, you can apply the changes to your current session with:
newgrp docker
This configuration has security implications because members of the docker group effectively have root privileges through the Docker daemon. Only add trusted users to this group.
Docker Daemon Configuration
The Docker daemon can be customized through the /etc/docker/daemon.json
file. If this file doesn’t exist, you can create it.
Here’s an example configuration file with some common settings:
{
"default-address-pools": [
{"base": "172.18.0.0/16", "size": 24}
],
"dns": ["8.8.8.8", "8.8.4.4"],
"log-driver": "json-file",
"log-opts": {
"max-size": "10m",
"max-file": "3"
},
"storage-driver": "overlay2"
}
After editing this file, restart the Docker daemon:
sudo systemctl restart docker
Setting up Docker to Start on Boot
Ensure Docker starts automatically when your system boots:
sudo systemctl enable docker
Verify that Docker is configured to start at boot time:
sudo systemctl is-enabled docker
This should return “enabled” if properly configured.
Docker Compose Setup
Docker Compose is a tool for defining and running multi-container Docker applications. If you installed Docker using the methods above, Docker Compose should be installed as a plugin.
Verifying Docker Compose Installation
Verify that Docker Compose is installed correctly:
docker compose version
This should display something like:
Docker Compose version v2.29.1
Basic Usage Examples
Create a simple Docker Compose file in your project directory:
# docker-compose.yml
version: '3'
services:
web:
image: nginx:latest
ports:
- "8080:80"
db:
image: mysql:5.7
environment:
MYSQL_ROOT_PASSWORD: example
MYSQL_DATABASE: myapp
Run the services defined in your compose file:
docker compose up -d
Stop and remove the containers:
docker compose down
Docker Desktop on Fedora 42 (Optional)
If you prefer a graphical interface for managing Docker containers, Docker Desktop is available for Fedora 42, though with certain limitations.
Installation Process
- Ensure you meet the prerequisites:
- 64-bit version of Fedora 42
- GNOME desktop environment with AppIndicator and KStatusNotifierItem extensions installed
- For non-GNOME environments, install gnome-terminal:
sudo dnf install gnome-terminal
- Download the latest RPM package from the Docker Desktop website.
- Install the package:
sudo dnf install ./docker-desktop-<version>-x86_64.rpm
- The installation process will set up the necessary components and integrations.
Launching and Using Docker Desktop
- Start Docker Desktop from the Applications menu or run:
systemctl --user start docker-desktop
- Accept the Docker Subscription Service Agreement when prompted.
- Docker Desktop will create a dedicated context for CLI operations to avoid conflicts with the local Docker Engine.
Desktop vs Engine Considerations
Consider these factors when choosing between Docker Desktop and Docker Engine:
- Docker Desktop requires a subscription for commercial use in larger enterprises
- Docker Desktop consumes more system resources
- Docker Desktop provides a graphical interface that simplifies container management
- Docker Engine is more lightweight and better suited for server environments
Managing Docker After Installation
Proper management ensures your Docker installation remains secure and up-to-date.
Updating Docker Engine
To update Docker when using the repository method:
sudo dnf update docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
If you installed Docker manually from package files, download the newer versions and repeat the installation process using dnf upgrade
instead of dnf install
.
Monitoring Docker Resources
Monitor Docker resource usage with built-in commands:
docker stats
This displays a live stream of container resource usage statistics.
To see the disk space used by Docker:
docker system df
Troubleshooting Common Installation Issues on Fedora 42
Fedora 42 users have reported some specific issues with Docker that should be addressed.
Permission Denied Errors
If you encounter “permission denied” errors when running Docker commands:
- Verify you’ve added your user to the docker group:
groups $USER
- If your user isn’t in the docker group, add it:
sudo usermod -aG docker $USER
- Log out and back in, or run:
newgrp docker
Network Connectivity Issues in Fedora 42
Some users have reported network connectivity issues with Docker after upgrading to Fedora 42. These issues are often related to iptables/nftables changes.
If your Docker containers can’t connect to the internet:
- Restart the Docker service:
sudo systemctl restart docker
- If containers still can’t connect, try pruning Docker networks:
sudo docker network prune -f
- For persistent issues, check if the problem is related to iptables by updating to the latest version:
sudo dnf install iptables-nft
Ensure you have at least version 1.8.11-5.fc42 or newer.
SELinux-Related Issues
SELinux can sometimes interfere with Docker operations:
- Check if SELinux is blocking Docker:
sudo ausearch -m avc --start recent | grep docker
- If SELinux issues are found, you can temporarily set SELinux to permissive mode for testing:
sudo setenforce 0
- For a permanent solution, configure SELinux policies correctly for Docker rather than disabling it.
Service Start Failures
If Docker fails to start:
- Check the service status for detailed error messages:
sudo systemctl status docker
- Review Docker daemon logs:
sudo journalctl -xu docker
- Verify that containerd is running:
sudo systemctl status containerd
Uninstalling Docker
If you need to remove Docker completely from your Fedora 42 system:
Removing Docker Packages
sudo dnf remove docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
Cleaning Up Docker Data
Docker’s default data location is /var/lib/docker
. To remove all Docker data:
sudo rm -rf /var/lib/docker
sudo rm -rf /var/lib/containerd
Also, remove any custom configuration files:
sudo rm -f /etc/docker/daemon.json
Congratulations! You have successfully installed Docker. Thanks for using this tutorial for installing the Docker containers on your Fedora 42 Linux system. For additional or useful information, we recommend you check the official Docker website.