Install Docker and compose-plugin
This guide explains how to install Docker and Docker-Compose on common Linux distributions.
Supported distributions in this guide:
- Debian / Ubuntu
- Arch Linux
- RHEL / Rocky / AlmaLinux / CentOS
- Fedora
Optional steps for allowing non-root users to run Docker are also included.
Table of Contents
- Requirements
- Debian / Ubuntu Installation
- Arch Linux Installation
- RHEL / Rocky / AlmaLinux / CentOS Installation
- Fedora Installation
- Verify the Installation
- Allow Non-Root Docker Usage (Optional)
Requirements
Before installing Docker, ensure that your system is updated.
sudo apt update
sudo apt upgrade
or on Arch:
sudo pacman -Syu
Debian / Ubuntu Installation
Install Docker using the official repository.
Install required packages
sudo apt install -y ca-certificates curl gnupg
Add the Docker GPG key
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/debian/gpg \
| sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg
Add the Docker repository
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] \
https://download.docker.com/linux/debian \
$(. /etc/os-release && echo $VERSION_CODENAME) stable" \
| sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
Install Docker
sudo apt update
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
Start Docker
sudo systemctl enable --now docker
Arch Linux Installation
Arch provides Docker directly in the official repositories.
Install Docker:
sudo pacman -S docker docker-compose
Enable and start the service:
sudo systemctl enable --now docker
RHEL / Rocky / AlmaLinux / CentOS Installation
Install required tools:
sudo dnf install -y dnf-plugins-core
Add the Docker repository:
sudo dnf config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
Install Docker:
sudo dnf install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
Start Docker:
sudo systemctl enable --now docker
Fedora Installation
Install Docker from the official repository.
Add the repository:
sudo dnf config-manager --add-repo https://download.docker.com/linux/fedora/docker-ce.repo
Install Docker:
sudo dnf install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
Start Docker:
sudo systemctl enable --now docker
Verify the Installation
Check if Docker is installed correctly.
docker --version
Check Docker Compose:
docker compose version
Test Docker by running a simple container:
sudo docker run hello-world
If the container runs successfully, Docker is installed correctly.
Allow Non-Root Docker Usage (Optional)
By default, Docker requires root privileges because it accesses the Docker socket.
To allow a normal user to run Docker commands without sudo, add the user to the docker group.
Create the Docker group (if it does not exist)
sudo groupadd docker
Add your user to the group
sudo usermod -aG docker $USER
Apply the group changes
Log out and log back in, or run:
newgrp docker
Test Docker without sudo
docker run hello-world
If it works without sudo, the permissions are configured correctly.
Notes
- Running Docker without root privileges works by granting access to the Docker socket:
/var/run/docker.sock
- Users in the
dockergroup effectively gain root-level permissions, so only trusted users should be added.