Docker: installing on the machine
How to install Docker properly on Debian, Ubuntu, and AlmaLinux, why the official repository is better than the system package, and what to check right after installation.
Updated August 23, 2026
Docker packages an application together with its entire environment into a container: you don't have to match library versions, and moving to another machine comes down to copying a config file. On a VDS with full root access it installs as standard.
Install from the official repository
The system repositories hold either an old version or docker.io without the Compose v2 plugin. The difference matters: half the guides online are written for the modern docker compose, not docker-compose.
Debian 12 and 13, Ubuntu 22.04 / 24.04 / 26.04:
sudo apt update
sudo apt install -y ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian $(. /etc/os-release && echo $VERSION_CODENAME) stable" | sudo tee /etc/apt/sources.list.d/docker.list
sudo apt update
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
For Ubuntu, replace debian with ubuntu in two places.
AlmaLinux 9 and 10, CentOS Stream 9:
sudo dnf -y install dnf-plugins-core
sudo dnf config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
sudo dnf -y install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
sudo systemctl enable --now docker
Verify the installation
docker --version
docker compose version
sudo docker run --rm hello-world
docker info | grep -E "Storage Driver|Cgroup|Docker Root Dir"
If hello-world downloaded and printed its greeting, everything works. The storage driver should be overlay2.
Working without sudo
sudo usermod -aG docker $USER
newgrp docker
The
dockergroup is equivalent to root. Anyone in it can run a container with the host root mounted and become an administrator. Only add people you would trust with root anyway — and never grant it to applications.
What to configure right away
Limit the logs, otherwise one chatty container will eat your disk. Create /etc/docker/daemon.json:
{
"log-driver": "json-file",
"log-opts": { "max-size": "20m", "max-file": "3" }
}
sudo systemctl restart docker
More details — container logs.
How much space it takes
Docker itself is about 500 MB; images and volumes grow from there. On VDS-1 with a 40 GB disk, two or three services fit, but you'll have to keep an eye on space: see disk space.
Common mistakes
- You mixed
docker.ioanddocker-ce. Firstsudo apt remove docker.io docker-compose, then install from the official repository. - Docker opened a port bypassing the firewall. Docker writes its own
iptablesrules, andufwdoesn't see them. Publish the port on the local interface —-p 127.0.0.1:8080:80— if you don't need it exposed. More details in Docker networking. - You forgot
--nowin systemctl on AlmaLinux. The service is enabled but not started; it will work after a reboot, but not right now.
Next: Docker Compose and volumes.