Dit deel is nog niet vertaald. Je ziet de Engelse tekst.
$ als gewone gebruiker# als root (of met sudo)
The quick answer
RHEL 9/10:
dnf -y install dnf-plugins-core
dnf config-manager --add-repo https://download.docker.com/linux/rhel/docker-ce.repo
dnf -y install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
systemctl enable --now docker
docker run --rm hello-worldUbuntu: add the key and the repository (step 3), then apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin.
Step by step
- Remove conflicting packages (RHEL has Podman and runc; Ubuntu may have
docker.io):
dnf -y remove docker docker-client docker-common podman runc
apt-get remove -y docker.io docker-compose podman-docker containerd runc- RHEL, Rocky, Alma: add the repo and install (step in the quick answer). Rocky and Alma use
https://download.docker.com/linux/centos/docker-ce.repo. When dnf asks about the GPG key, check the fingerprint060A 61C5 1B55 8A7F 742B 77AA C52F EB6B 621E 9F35. - Ubuntu and Debian:
apt-get update
apt-get install -y ca-certificates curl
install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
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" > /etc/apt/sources.list.d/docker.list
apt-get update
apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin- Day-one settings — log rotation (container logs can fill the disk) and, if needed, another data folder:
{
"log-driver": "json-file",
"log-opts": { "max-size": "10m", "max-file": "3" },
"live-restore": true
}systemctl restart docker
docker info --format '{{.LoggingDriver}} {{.DockerRootDir}}'
json-file /var/lib/dockerAdd "data-root": "/data/docker" when /var is small (stop Docker and move the folder first).
- Use it without sudo — only for trusted admins. The
dockergroup is the same as root on that host:
On shared servers keep sudo docker, or use rootless mode.
Check that it worked
Common problems
| Problem | Cause | Fix |
|---|---|---|
Cannot connect to the Docker daemon | The service is not running, or no right on the socket. | systemctl start docker; use sudo or the docker group. |
permission denied … docker.sock after adding the group | The group is read at login. | Log out and in (or newgrp docker). |
Package conflicts with podman / runc (RHEL) | Podman packages are installed. | Remove them first (step 1), or use Podman instead of Docker. |
docker-compose: command not found | Compose v2 is a plugin: docker compose (space). | Use docker compose; install docker-compose-plugin. |
Disk full under /var/lib/docker | Old images, build cache, big logs. | docker system df; prune; log rotation (step 4). |
| Published ports open although the firewall denies them | Docker writes its own firewall rules. | Bind to 127.0.0.1:PORT when a proxy is in front. |
Go further
- Command pages: docker, systemctl, usermod.
- Next how-tos: Run a container and publish a port, See the logs of a container, Free disk space used by Docker.
- Full guide: Install and set up Docker. Other engines: Podman.
- Learn it: Docker — Containers vs VMs, Docker — Run. At work: docker in daily use.
1Why is adding a user to the docker group a security decision?
A member can start a container that mounts / and change any file — it is like root.
2Where do you set log rotation for all containers?
In /etc/docker/daemon.json (log-opts max-size and max-file), then restart Docker.