Installing
To install the Docker Engine you need a 64-bit operating system. Today there are basically three paths:
- Docker Desktop — for Windows, macOS and also Linux. It installs the Docker Engine, the CLI, Docker Compose, Buildx and a graphical interface. Recommended for development machines.
- Docker Engine — only the daemon and the CLI, installed directly on Linux from a package repository. Recommended for servers.
- Convenience script (
get.docker.com) — a shortcut for test environments.
What about the virtual machine?
You no longer need a VM with a bridged network interface to follow the
examples. Docker running natively on Linux, on WSL 2 (Windows) or on Docker
Desktop (macOS) covers everything we will see here. If you do use a VM,
remember to reach the services through its IP, not through localhost.
Docker Desktop
- Docker Desktop for Windows (requires WSL 2)
- Docker Desktop for macOS (Apple Silicon or Intel)
- Docker Desktop for Linux
After installing, verify with:
docker version
docker compose version
docker run hello-world
Docker Engine on Linux (Ubuntu/Debian)
The procedure below follows the
official documentation and uses the
current repository key format (/etc/apt/keyrings), since apt-key has been
deprecated.
Remove old or conflicting packages, if any:
for pkg in docker.io docker-doc docker-compose docker-compose-v2 podman-docker containerd runc; do
sudo apt-get remove -y $pkg
done
Set up the Docker repository:
sudo apt-get update
sudo apt-get install -y ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
# swap "ubuntu" for "debian" if that is your case
sudo curl -fsSL https://download.docker.com/linux/ubuntu/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/ubuntu $(. /etc/os-release && echo "$VERSION_CODENAME") stable" \
| sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
Install the Engine, the CLI, containerd and the Buildx and Compose plugins:
sudo apt-get install -y \
docker-ce \
docker-ce-cli \
containerd.io \
docker-buildx-plugin \
docker-compose-plugin
Test:
sudo docker run hello-world
To run docker without sudo, add your user to the docker group and restart
the session:
sudo usermod -aG docker "$USER"
Convenience script
Quick for disposable VMs and test environments. Not recommended for production.
curl -fsSL https://get.docker.com | sh
sudo usermod -aG docker "$USER"
Log out and log back in for the docker group to take effect.