Playbook

Install Docker

Docker Engine, Buildx and the Compose plugin from Docker's own repositories.

Category

Runtimes

Time limit per server

30 minutes

Temporary failures

Retried automatically, up to 2 times

Version

1.0

Supported systems

Ubuntu 22.04+, Debian 12+, RHEL-compatible 8+ (AlmaLinux, Rocky Linux, RHEL, CentOS Stream, Oracle Linux), Amazon Linux 2023+. Still runs on Debian 11, which is past the end of standard support.

Options

As they appear on the run form, with their defaults.

Install the Compose plugin

On or off

Provides docker compose.

Default: On

When to use it

Before running containers on a server, and before Start Monitoring Stack, which runs on Docker. The Docker Host template runs this playbook after updating the server's packages.

Choosing the options

Install the Compose plugin — keep it on unless you are sure nothing on the server will use docker compose. Compose is how most multi-container applications are started, and the monitoring stack needs it.

What it does on the server

  1. Looks for an existing Docker. A server that already runs Docker from docker-ce, docker.io or moby-engine keeps that engine; the playbook only makes sure it is enabled and running, and adds Compose if asked.
  2. On Ubuntu and Debian, adds Docker's apt repository after checking that the downloaded key is Docker's published release key (fingerprint 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88), then installs docker-ce, docker-ce-cli, containerd.io and docker-buildx-plugin.
  3. On the RHEL family, adds Docker's docker-ce.repo with its key checked the same way, and installs the same packages.
  4. On Amazon Linux 2023, installs Amazon's own docker package, and Compose from Docker's GitHub releases, checked against the checksum published with the release.
  5. Enables and starts Docker, then confirms the engine answers and docker compose version works.

It never removes a package. If Docker's packages would replace the distribution's containerd or runc, or Podman's podman-docker wrapper, it stops before changing anything and says which.

After the run

The result line shows the Docker Engine and Compose versions. Run containers with your own tooling, over SSH or with the Command Runner.

Ports you publish from containers (-p 8080:80) are opened by Docker itself and are not filtered by ufw or firewalld. Publish to 127.0.0.1:8080:80 anything that should only be reachable from the server, and put a reverse proxy in front of it.

Common problems

"…'s own containerd package is installed, and Docker's packages would replace it." — Something may be using the distribution's containerd; Kubernetes often does. If nothing needs it, remove it with the Command Runner (apt-get remove -y containerd runc) and run the playbook again.

"The docker command on this server is Podman's compatibility wrapper (podman-docker)." — Remove podman-docker first if you want Docker Engine instead of Podman.

"This playbook installs Docker on x86_64 and aarch64 servers" — Docker publishes packages for those two architectures only.

"Docker is installed and its service is running, but the engine did not answer." — Check journalctl -u docker on the server. A broken /etc/docker/daemon.json is the usual cause.

Ubuntu 20.04 is refused — Docker no longer publishes updates for Ubuntu 20.04. Upgrade the server's release, or use a newer server.