mirror of
https://github.com/luzifer-ansible/docker-compose.git
synced 2024-11-09 14:00:05 +00:00
Fix: Ensure docker-compose is restarted on docker restart
Previously restarting docker.service (e.g. on an update) caused docker-compose to be shut down and not being restarted. This caused services started by docker-compose not to be started and the system to have no running containers. This fix chains docker-compose directly to docker and therefore systemd will start docker-compose when docker comes up again. Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
7336f24368
commit
3087b329e5
1 changed files with 14 additions and 1 deletions
|
@ -36,6 +36,19 @@
|
||||||
|
|
||||||
# Install and start services
|
# Install and start services
|
||||||
|
|
||||||
|
- name: '[Migration] Check multi-user.target dependency of service'
|
||||||
|
command: grep -Fxq 'WantedBy=multi-user.target' /etc/systemd/system/docker-compose.service
|
||||||
|
register: docker_compose_olddep
|
||||||
|
check_mode: no
|
||||||
|
ignore_errors: yes
|
||||||
|
changed_when: no
|
||||||
|
|
||||||
|
- name: '[Migration] Disable service still WantedBy=multi-user.target'
|
||||||
|
systemd:
|
||||||
|
name: docker-compose.service
|
||||||
|
enabled: no
|
||||||
|
when: docker_compose_olddep.rc == 0
|
||||||
|
|
||||||
- name: Install docker-compose.service
|
- name: Install docker-compose.service
|
||||||
copy:
|
copy:
|
||||||
dest: /etc/systemd/system/docker-compose.service
|
dest: /etc/systemd/system/docker-compose.service
|
||||||
|
@ -59,7 +72,7 @@
|
||||||
ExecReload=/usr/local/bin/docker-compose up -d --remove-orphans
|
ExecReload=/usr/local/bin/docker-compose up -d --remove-orphans
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=docker.service
|
||||||
register: docker_compose_service
|
register: docker_compose_service
|
||||||
|
|
||||||
- name: Start and enable docker-compose service
|
- name: Start and enable docker-compose service
|
||||||
|
|
Loading…
Reference in a new issue