Docker has become the industry standard for running applications in lightweight, portable containers. Whether you're using a Linux distribution like AlmaLinux, Alpine, Rocky Linux, Ubuntu, CentOS, Debian, Fedora, or even FreeBSD, setting up Docker is quick and straightforward. In this guide, we'll walk you through the complete Docker installation process step by step, so you can get started with containerized applications on your favorite operating system.
Why Use Docker?
Docker has become one of the most popular tools for developers, system administrators, and businesses because it makes building, deploying, and running applications easier than ever. Here are some key reasons to use Docker:
- Lightweight & Fast – Docker containers share the host operating system kernel, making them faster and more resource-efficient than traditional virtual machines.
- Portability – Build once, run anywhere. A Docker container runs the same on your laptop, cloud server, or data center.
- Simplified Deployment – Package your application with all its dependencies into a single container, ensuring consistency across environments.
- Scalability – Works seamlessly with orchestration tools like Kubernetes and Docker Swarm to scale applications quickly.
- Isolation & Security – Each container runs in its own isolated environment, reducing conflicts between applications.
- DevOps Friendly – Perfect for CI/CD pipelines, automated testing, and microservices architecture.
- Huge Ecosystem – Access thousands of pre-built images on Docker Hub for databases, programming languages, web servers, and more.
In short: Docker saves time, reduces errors, and ensures your applications run consistently everywhere.
How to Install Docker on AlmaLinux
Docker can be installed on AlmaLinux using the official Docker repository.
Step 1: Update Your System
sudo dnf update -y
Step 2: Install Required Packages
sudo dnf install -y yum-utils device-mapper-persistent-data lvm2
These packages allow you to manage repositories and storage drivers needed for Docker.
Step 3: Add the Docker Repository
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
Docker uses the CentOS repository for AlmaLinux.
Step 4: Install Docker Engine
sudo dnf install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
Step 5: Start and Enable Docker
sudo systemctl start docker
sudo systemctl enable docker
Step 6: Verify Docker Installation
sudo docker --version
How to Install Docker on Alpine Linux
Alpine Linux is a lightweight distribution, making Docker installation simple using the apk package manager.
Step 1: Update Your System
sudo apk update
sudo apk upgrade
Step 2: Install Docker
sudo apk add docker
This installs the Docker Engine and Docker CLI.
Step 3: Start and Enable Docker
sudo rc-update add docker boot
sudo service docker start
Step 4: Verify Docker Installation
docker --version
How to Install Docker on Rocky Linux
Rocky Linux is a RHEL-based distribution, so Docker installation is nearly identical to AlmaLinux.
Step 1: Update Your System
sudo dnf update -y
Step 2: Install Required Packages
sudo dnf install -y yum-utils device-mapper-persistent-data lvm2
Step 3: Add the Docker Repository
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
Docker uses the CentOS repository for Rocky Linux.
Step 4: Install Docker Engine
sudo dnf install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
Step 5: Start and Enable Docker
sudo systemctl start docker
sudo systemctl enable docker
Step 6: Verify Docker Installation
docker --version
How to Install Docker on Ubuntu
Ubuntu provides an easy method to install Docker using the official Docker repository.
Step 1: Update Your System
sudo apt update
sudo apt upgrade -y
Step 2: Install Required Packages
sudo apt install -y ca-certificates curl gnupg lsb-release
Step 3: Add Docker's GPG Key
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | \
sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
Step 4: Add Docker Repository
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] \
https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
Step 5: Install Docker Engine
sudo apt update
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
Step 6: Start and Enable Docker
sudo systemctl start docker
sudo systemctl enable docker
Step 7: Verify Docker Installation
docker --version
How to Install Docker on CentOS
CentOS installation follows the same process as AlmaLinux and Rocky Linux.
Step 1: Update Your System
sudo yum update -y
Step 2: Install Required Packages
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
Step 3: Add the Docker Repository
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
Step 4: Install Docker Engine
sudo yum install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
Step 5: Start and Enable Docker
sudo systemctl start docker
sudo systemctl enable docker
Step 6: Verify Docker Installation
docker --version
How to Install Docker on Debian
Debian supports installing Docker from the official Docker repository.
Step 1: Update Your System
sudo apt update
sudo apt upgrade -y
Step 2: Install Required Packages
sudo apt install -y ca-certificates curl gnupg lsb-release
Step 3: Add Docker's GPG Key
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/debian/gpg | \
sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
Step 4: Add Docker Repository
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] \
https://download.docker.com/linux/debian \
$(lsb_release -cs) stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
Step 5: Install Docker Engine
sudo apt update
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
Step 6: Start and Enable Docker
sudo systemctl start docker
sudo systemctl enable docker
Step 7: Verify Docker Installation
docker --version
How to Install Docker on Fedora
Fedora provides an easy way to install Docker using Docker's official repository.
Step 1: Update Your System
sudo dnf update -y
Step 2: Install Required Packages
sudo dnf install -y dnf-plugins-core
This package enables management of additional repositories.
Step 3: Add the Docker Repository
sudo dnf config-manager --add-repo https://download.docker.com/linux/fedora/docker-ce.repo
Step 4: Install Docker Engine
sudo dnf install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
Step 5: Start and Enable Docker
sudo systemctl start docker
sudo systemctl enable docker
Step 6: Verify Docker Installation
docker --version