Skip to content
Snippets Groups Projects

Webarchitects Ansible Docker Role

pipeline status

Ansible Role to install Docker CE on Debian and Ubuntu.

This role can also optionally install the last version of docker-compose version 1, Docker Compose 1.29.2 and Compose Switch.

See the defaults/main.yml for the default settings and vars/main.yml for the gpg and apt variables.

Variable name Default value Comment
docker true Set to false for the tasks in this role to be skipped
docker_compose_v1 UNDEFINED Set to false for Docker Composer version 1 to be removed and set to true for docker-compose version 1 and docker-compose-switch to be installed
docker_compose_version_v1 1.29.2 The version number of docker-compose version 1 to be installed when docker_compose_v1 is defined and true
docker_daemon
  storage-driver: overlay2
  log-driver: syslog
Docker daemon configuration, YAML that will converted to JSON and written to /etc/docker/daemon.json
docker_pkg
  - containerd.io
  - docker-ce
  - docker-ce-cli
  - docker-ce-rootless-extras
  - docker-compose-plugin
Packages to be installed from the Docker apt repo

See the documentation for the Docker daemon config file for all the options available and convert these to YAML for use by this role, for example:

docker_daemon:
  storage-driver: overlay2
  log-driver: syslog
  dns:
    - 1.1.1.1
    - 8.8.8.8
    - 9.9.9.9

The role uses .sources rather than .list files for apt and it also checks the gpg public key used to sign packages against the vars/main.yml and limits what packages can be installed from the Docker repo, based on the Debian wiki page with instructions to connect to a third-party repository.

This role requires jc version 1.20.2 or later to be installed on the Ansible controller using pip for the parsing of GPG command output, jc can be installed using Ansible, or simply run:

pip3 install jc

The primary URL of this repo is https://git.coop/webarch/docker however it is also mirrored to GitHub and available via Ansible Galaxy.

If you use this role please use a tagged release, see the release notes.

See also the localhost repo for using this role to install Docker on the localhost.