Ability to configure Docker daemon options

This commit is contained in:
Ricky Kwan 2018-10-08 18:53:22 +00:00
parent a42939be87
commit 33afdbb0f8
3 changed files with 22 additions and 0 deletions

View File

@ -52,6 +52,13 @@ Docker Compose installation options.
A list of system users to be added to the `docker` group (so they can use Docker on the server). A list of system users to be added to the `docker` group (so they can use Docker on the server).
docker_daemon_options:
storage-driver: "devicemapper"
log-opts:
max-size: "100m"
Custom `dockerd` options can be configured through this dictionary representing the json file `/etc/docker/daemon.json`.
## Use with Ansible (and `docker` Python library) ## Use with Ansible (and `docker` Python library)
Many users of this role wish to also use Ansible to then _build_ Docker images and manage Docker containers on the server where Docker is installed. In this case, you can easily add in the `docker` Python library using the `geerlingguy.pip` role: Many users of this role wish to also use Ansible to then _build_ Docker images and manage Docker containers on the server where Docker is installed. In this case, you can easily add in the `docker` Python library using the `geerlingguy.pip` role:

View File

@ -27,3 +27,6 @@ docker_yum_repo_enable_test: 0
# A list of users who will be added to the docker group. # A list of users who will be added to the docker group.
docker_users: [] docker_users: []
# Docker daemon options
docker_daemon_options: {}

View File

@ -17,6 +17,18 @@
state: "{{ docker_service_state }}" state: "{{ docker_service_state }}"
enabled: "{{ docker_service_enabled }}" enabled: "{{ docker_service_enabled }}"
- name: Ensure /etc/docker/ directory exists.
file:
path: /etc/docker
state: directory
- name: Configure docker daemon options.
copy:
content: "{{ docker_daemon_options | to_nice_json }}"
dest: /etc/docker/daemon.json
mode: 0644
notify: restart docker
- name: Ensure handlers are notified now to avoid firewall conflicts. - name: Ensure handlers are notified now to avoid firewall conflicts.
meta: flush_handlers meta: flush_handlers