Docker: override the systemd unit to enable the http socket needed by the external clients.

This commit is contained in:
Andrea Dell'Amico 2019-09-25 03:16:29 +02:00
parent 4920fb8473
commit cdb49768b0
3 changed files with 27 additions and 0 deletions

View File

@ -30,5 +30,6 @@ docker_user_home: /home/docker
docker_defaults_file: /etc/default/docker
docker_enable_tcp_socket: False
docker_tcp_socket_port: 2375
docker_api_port: 2376
docker_tcp_socket_host: 127.0.0.1

View File

@ -19,8 +19,27 @@
- name: Install the Docker default options
template: src=docker-default.j2 dest={{ docker_defaults_file }} owner=root group=root mode=0644
when: ansible_service_mgr != 'systemd'
notify: Restart docker
- name: Create the docker service systemd directory
file: dest=/etc/systemd/system/docker.service.d state=directory mode=0755
when: ansible_service_mgr == 'systemd'
tags: [ 'docker', 'docker_systemd' ]
- name: Install the Docker additional systemd unit
template: src=docker-systemd-override.conf.j2 dest=/etc/systemd/system/docker.service.d/override.conf owner=root group=root mode=0644
when: ansible_service_mgr == 'systemd'
notify: Restart docker
register: reload_systemd
tags: [ 'docker', 'docker_systemd' ]
- name: systemd reload
command: systemctl daemon-reload
when: reload_systemd is defined and reload_systemd is changed
tags: [ 'docker', 'docker_systemd' ]
- name: Ensure that the service is started and enabled
service: name=docker state=started enabled=yes

View File

@ -0,0 +1,7 @@
[Service]
ExecStart=
{% if docker_swarm %}
ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:{{ docker_api_port }} -H fd:// --containerd=/run/containerd/containerd.sock
{% else %}
ExecStart=/usr/bin/dockerd {% if docker_enable_tcp_socket %} -H tcp://{{ docker_tcp_socket_host }}:{{ docker_tcp_socket_port }} {% endif %} -H fd:// --containerd=/run/containerd/containerd.sock
{% endif %}