hamidyousefi.docker
Docker Ansible Role
This is a simple Ansible Role for installing Docker as a systemd service. I use this role for various personal and work projects, and I'll keep it updated and customizable based on what I find helpful (and so will others).
Supported Distributions
Currently, these operating systems and their versions are tested:
- Debian
- Jessie
- Stretch
- Buster
- Ubuntu
- Xenial
- Bionic
- Focal
How to Use It
You can easily install this role on your machine or servers using the command below:
ansible-galaxy install hamidyousefi.docker
If you have a playbook, you can add the following lines to your roles/requirements.yml
. If this file doesn’t exist yet, you can create it.
- name: hamidyousefi.docker
version: master
master
is the latest version of this role. You can specify a different version, like v1.3.0
, by replacing master
. You can find available versions and their change logs on the releases page.
Logging into Registries
This role can log in users to specified registries. The example below shows how to do this:
docker_registries:
- user: linux-user
url: registry.domain.tld
username: registry-username
password: '123456'
Extra Features and Configurations
I included some additional features in this role. You can easily set up docker-compose
and service-level proxies by adding the following block to your group_vars
or host_vars
YAML files.
Docker Compose
docker-compose
is installed by default. If you don't want to install it, add this to your variables:
extensions: []
You can also add your docker-compose.yml
files to the remote host at specified paths. Set the following in your group or host variables:
docker_compose:
- template_path: where-the-template-placed/docker-compose.yml.j2
destination_path: path-to-place/docker-compose.yml
HTTP(S) Proxy
To set up an HTTP and/or HTTPS proxy for Docker, add these variables:
docker_proxy:
http: 'http://your-server:80'
https: 'https://your-server:443'
Docker Service Installation
ansible-galaxy install hamidyousefi.docker