This Ansible role installs and configures Docker and the Docker Compose plugin on an Debian/Ubuntu system.
- Installs required Docker dependencies
- Adds the official Docker GPG key
- Configures the Docker APT repository
- Installs Docker Engine, CLI, Containerd, and the Docker Compose plugin
- Ensures Docker service is running and enabled at boot
- Validates Docker and Docker Compose installation
- Provides a success message after installation
- Debian 12 (Bookworm) or
- Ubuntu 20.04 (Focal), 22.04 (Jammy), or 24.04 (Noble)
- Root privileges (become: true)
- The
ansibleuser should exist (or adjust accordingly)
Example Playbook:
- hosts: your_target_machines
become: true
roles:
- role: docker_installdocker: Installs, configures, and validates Docker.
- This role uses the new Docker Compose v2 plugin (
docker composeinstead of the legacydocker-composecommand). - The
ansibleuser is added to thedockergroup to allow Docker commands withoutsudo.
- Created by Mirco Schmidt