How To Install Docker Compose on Fedora 43

Docker Compose has become an indispensable tool for developers and system administrators who work with containerized applications. This powerful orchestration tool simplifies the deployment and management of multi-container Docker applications through simple YAML configuration files. Whether you’re running a web application with a database backend or deploying complex microservices architectures, Docker Compose streamlines the entire process on Fedora 43.
Fedora 43, as one of the cutting-edge Linux distributions, provides excellent support for containerization technologies. This comprehensive guide walks you through multiple installation methods for Docker Compose, ensuring you can choose the approach that best fits your requirements. You’ll learn how to install, configure, verify, and troubleshoot Docker Compose on your Fedora 43 system, along with essential commands and best practices for daily operations.
Understanding Docker Compose
Docker Compose is a tool designed to define and run multi-container Docker applications. Unlike Docker, which manages individual containers, Compose allows you to orchestrate multiple containers simultaneously using a single configuration file. This distinction is crucial for modern application development.
The latest version, Docker Compose v2, represents a significant architectural shift from its predecessor. Instead of running as a standalone application, Compose v2 operates as a plugin to the Docker CLI. This means you’ll use docker compose (with a space) instead of the older docker-compose (with a hyphen) command syntax.
Docker Compose excels in several scenarios. Development environments benefit from consistent, reproducible setups across team members. Production deployments gain simplified management of interconnected services. Testing environments can be spun up and torn down rapidly. The tool’s ability to define networking, volumes, environment variables, and dependencies in a single YAML file makes it invaluable for modern DevOps workflows.
Prerequisites
Before installing Docker Compose on Fedora 43, ensure your system meets specific requirements. You’ll need a running Fedora 43 installation with either root access or sudo privileges. The system should have adequate resources—at least 2GB of RAM and 20GB of available disk space for Docker operations.
Network connectivity is essential for downloading packages from repositories. Your Fedora 43 system should be up-to-date to avoid compatibility issues. Basic familiarity with command-line operations will help you follow the installation steps smoothly.
While not strictly required, understanding Docker fundamentals enhances your Docker Compose experience. Knowing how containers work, what images are, and basic Docker commands provides context for Compose’s capabilities.
Method 1: Installing Docker Compose via Fedora Repository
The Fedora repository method offers the simplest installation path. This approach uses Fedora’s native package manager and provides packages maintained by the Fedora community.
Step 1: Update System Packages
Start by updating your system packages to ensure compatibility and security. Open your terminal and execute:
sudo dnf update -y
This command refreshes package metadata and upgrades installed packages. The -y flag automatically confirms the operation. Wait for the process to complete before proceeding.
Step 2: Install Docker CLI and Dependencies
Install the Docker command-line interface and container runtime with this command:
sudo dnf install docker-cli containerd -y
The docker-cli package provides the Docker command-line client, allowing you to interact with Docker services. The containerd package is the industry-standard container runtime that manages container lifecycle operations. DNF automatically resolves and installs any additional dependencies.
Step 3: Install Docker Compose Plugin
Now install the Docker Compose plugin, which implements Compose v2 functionality:
sudo dnf install docker-compose -y
This package integrates Compose as a Docker plugin, enabling you to use the docker compose command structure. The plugin architecture provides better integration with Docker CLI and improved performance compared to the standalone v1 implementation.
Step 4: Install Docker Compose CLI Wrapper (Optional)
If you prefer using the traditional docker-compose command syntax, install the compose-switch wrapper:
sudo dnf install docker-compose-switch -y
This wrapper translates docker-compose commands to the new docker compose plugin syntax, maintaining backward compatibility with existing scripts and workflows. It’s particularly useful when migrating from older Docker Compose versions.
Method 2: Installing Docker Compose via Docker’s Official Repository
Docker’s official repository provides the most current versions and updates. This method gives you access to Docker Community Edition (Docker CE) with all official plugins.
Step 1: Remove Conflicting Packages
Before installing from Docker’s repository, remove any existing Docker installations:
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
This step prevents package conflicts that could cause installation failures. Don’t worry if some packages aren’t found—this simply means they weren’t installed.
Step 2: Install DNF Plugins Core
Install the DNF plugins package to enable repository management capabilities:
sudo dnf -y install dnf-plugins-core
This package provides the config-manager command used in the next step. It’s essential for adding third-party repositories to your Fedora system.
Step 3: Add Docker’s Official Repository
Add Docker’s official Fedora repository to your system:
sudo dnf config-manager --add-repo https://download.docker.com/linux/fedora/docker-ce.repo
This command downloads and configures the repository file, allowing DNF to access Docker’s package archives. The official repository ensures you receive updates directly from Docker.
Step 4: Install Docker Engine and Compose Plugin
Execute this comprehensive installation command:
sudo dnf install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y
Let’s break down what each package provides. The docker-ce package is Docker Engine itself—the core daemon that runs containers. docker-ce-cli is the command-line interface for interacting with Docker. containerd.io serves as the container runtime. docker-buildx-plugin enhances Docker’s build capabilities with multi-platform support. Finally, docker-compose-plugin installs Compose v2 as a Docker plugin.
During installation, you’ll be prompted to accept Docker’s GPG key. Verify the fingerprint matches: 060A 61C5 1B55 8A7F 742B 77AA C52F EB6B 621E 9F35. This step ensures package authenticity and security.
Step 5: Start and Enable Docker Service
Start the Docker service and enable it to launch at boot:
sudo systemctl enable --now docker
The --now flag starts the service immediately while enable ensures it starts automatically on system boot. Verify the service status with:
sudo systemctl status docker
You should see “active (running)” in the output, confirming successful service initialization.
Method 3: Installing Moby Engine with Docker Compose
Moby Engine is the open-source upstream project for Docker. Some users prefer Moby for its completely open-source nature and Fedora-native packaging.
Install Moby Engine and related packages:
sudo dnf install moby-engine containerd -y
Then add Docker Compose:
sudo dnf install docker-compose -y
Moby Engine provides functionality equivalent to Docker CE but follows Fedora’s packaging standards more closely. Choose this method if you prefer Fedora-maintained packages or need an entirely open-source solution without Docker’s commercial components.
Method 4: Using Podman with Docker Compose
Podman represents a modern alternative to Docker, offering several advantages for Fedora users. This daemonless container engine runs containers without requiring a background service, improving security through its rootless design.
Install Podman with Docker Compose compatibility:
sudo dnf install podman docker-compose -y
For Docker CLI compatibility, install the podman-docker package:
sudo dnf install podman-docker -y
This package creates a compatibility layer that translates Docker commands to Podman equivalents. Enable the Podman socket to ensure Docker Compose can communicate with Podman:
sudo systemctl enable --now podman.socket
Podman’s architecture eliminates single points of failure inherent in daemon-based systems. It provides better integration with systemd and supports rootless containers out of the box. However, note that some Docker Compose features may have limitations when running with Podman.
Post-Installation Configuration
After installation, configure your system for optimal Docker Compose usage.
Adding User to Docker Group
By default, Docker commands require root privileges. Add your user to the docker group for convenience:
sudo usermod -aG docker $USER
This command grants your user account permission to communicate with the Docker daemon. Log out and back in for the changes to take effect. While convenient, understand that docker group members have effective root access to the system.
Starting Docker Service on Boot
If you didn’t use the --now flag earlier, enable Docker to start automatically:
sudo systemctl enable docker
Verify the configuration:
sudo systemctl is-enabled docker
The output should confirm “enabled” status.
Configuring Firewall Rules
Fedora’s firewalld may require configuration for container networking. Docker typically manages its own iptables rules, but you might need to allow specific ports:
sudo firewall-cmd --zone=public --add-masquerade --permanent
sudo firewall-cmd --reload
These commands enable network address translation for containers, allowing them to access external networks. Adjust firewall rules based on your specific security requirements.
Verifying Docker Compose Installation
Confirm your installation succeeded by checking the Docker Compose version:
docker compose version
You should see output indicating Docker Compose version 2.x.x. If you installed docker-compose-switch, this alternative command also works:
docker-compose --version
Test Docker Engine functionality with the hello-world image:
sudo docker run hello-world
If you added your user to the docker group, omit sudo. This command downloads a test image and runs it in a container. Successful execution prints a welcome message explaining Docker’s operation flow.
Check running containers:
docker ps
Initially, this shows no containers since the hello-world container exits immediately after printing its message.
Creating Your First Docker Compose File
Docker Compose uses YAML files to define application stacks. Create a simple example to understand the structure. Make a new directory for your project:
mkdir ~/my-docker-app
cd ~/my-docker-app
Create a file named docker-compose.yml:
version: '3.8'
services:
web:
image: nginx:latest
ports:
- "8080:80"
volumes:
- ./html:/usr/share/nginx/html
restart: unless-stopped
This configuration defines a single service named “web” running Nginx. The ports section maps port 8080 on your host to port 80 in the container. The volumes section mounts a local directory to serve web content. The restart policy ensures the container restarts automatically unless you explicitly stop it.
Create the HTML directory and add a simple page:
mkdir html
echo "Hello from Docker Compose!" > html/index.html
YAML syntax is whitespace-sensitive. Use spaces, not tabs, for indentation. Maintain consistent indentation levels throughout the file.
Running Your First Docker Compose Application
Launch your application with:
docker compose up
Docker Compose pulls the Nginx image if not already present, creates the container, and starts the service. Output streams to your terminal, showing real-time logs. Press Ctrl+C to stop.
For background execution, use detached mode:
docker compose up -d
The -d flag runs containers in the background. View running services:
docker compose ps
Access your application by opening a web browser and navigating to http://localhost:8080. You should see your HTML page.
View container logs:
docker compose logs
Add -f to follow logs in real-time. Stop and remove your application:
docker compose down
This command stops containers and removes them along with networks created by Compose.
Essential Docker Compose Commands
Master these commands for effective Docker Compose usage:
docker compose up starts all services defined in your compose file. Use -d for detached mode and --build to rebuild images.
docker compose down stops and removes containers, networks, and volumes (with -v flag).
docker compose ps lists containers for the current compose project, showing their status.
docker compose logs displays output from containers. Use -f for live streaming and --tail=50 to limit output.
docker compose exec runs commands inside running containers. For example, docker compose exec web bash opens a shell in the web service.
docker compose build builds or rebuilds images defined in your compose file without starting containers.
docker compose pull downloads updated images for services using pre-built images.
docker compose restart restarts services without recreating containers, useful for configuration changes that don’t require container recreation.
Troubleshooting Common Installation Issues
Even straightforward installations can encounter problems. Here’s how to resolve common issues.
Permission Denied Errors
If you see “permission denied” when running Docker commands, verify your user group membership:
groups $USER
If “docker” doesn’t appear, ensure you logged out and back in after adding yourself to the group. Alternatively, use newgrp docker to activate the group membership immediately.
Service Failed to Start
When Docker service won’t start, check systemd logs:
sudo journalctl -xeu docker.service
Common causes include conflicting services, corrupted Docker daemon configuration, or insufficient system resources. Review the logs for specific error messages.
Repository Connection Issues
If repository downloads fail, verify your network connection and DNS resolution. Check if a proxy is required:
sudo dnf config-manager --add-repo https://download.docker.com/linux/fedora/docker-ce.repo --setopt=proxy=http://proxy.example.com:8080
Adjust the proxy URL to match your environment.
Package Conflict Errors
Dependency conflicts typically arise from incomplete removal of old Docker versions. Perform a clean installation:
sudo dnf remove docker-*
sudo dnf autoremove
sudo rm -rf /var/lib/docker
sudo rm -rf /etc/docker
Then retry the installation. Note that removing /var/lib/docker deletes all images, containers, and volumes.
SELinux Context Issues
Fedora’s SELinux enforcement can affect container operations. If you encounter permission errors with volume mounts, append :z or :Z to volume definitions in your compose file:
volumes:
- ./data:/app/data:z
The lowercase z allows sharing between containers. The uppercase Z provides exclusive access. This sets appropriate SELinux contexts automatically.
Best Practices for Docker Compose on Fedora 43
Following best practices ensures reliable, secure Docker Compose deployments.
Keep Docker and Compose updated regularly:
sudo dnf update docker-ce docker-ce-cli docker-compose-plugin
Use .env files for environment-specific configuration instead of hardcoding values in compose files. Store sensitive data like passwords and API keys in secrets or external secret management systems.
Organize multi-container projects with clear directory structures. Group related services and maintain separate compose files for development, staging, and production environments.
Implement resource limits to prevent containers from consuming excessive system resources:
services:
web:
image: nginx
deploy:
resources:
limits:
cpus: '0.5'
memory: 512M
Consider rootless Docker or Podman for enhanced security. These options reduce the attack surface by avoiding root-level daemon processes.
Backup Docker volumes regularly. Use volume backup containers or direct file system backups for persistent data. Establish automated backup schedules for production environments.
Updating and Managing Docker Compose
Maintain your Docker Compose installation with regular updates. Check for available updates:
sudo dnf check-update docker-compose-plugin
Update Docker Compose along with other system packages:
sudo dnf update docker-compose-plugin
When updating Docker Engine, update all components together to maintain compatibility:
sudo dnf update docker-ce docker-ce-cli containerd.io docker-compose-plugin
Clean up unused resources periodically to reclaim disk space:
docker system prune -a
This removes stopped containers, unused networks, dangling images, and build cache. Add -f to skip confirmation. Use this command cautiously in production environments.
Manage multiple Compose projects by organizing them in separate directories. Docker Compose uses the directory name as the project name by default, keeping resources isolated.
Congratulations! You have successfully installed Docker Compose. Thanks for using this tutorial for installing Docker Compose on your Fedora 43 Linux system. For additional or useful information, we recommend you check the official Docker website.