I installed docker with snap. Every time snap updates docker, snap.docker.dockerd (default) service gets stopped and started after some time. I have a docker-compose app running so every update my app just goes down.
Docker compose's option restart doesn't work for me because of bug (https://github.com/docker/for-win/issues/584)
So the only option I see is to use systemd service. Here it is (/etc/systemd/system/docker-compose-chebur.service):
[Unit]
Description=Docker Compose Chebur
Requires=snap.docker.dockerd.service
PartOf=snap.docker.dockerd.service
After=snap.docker.dockerd.service
[Service]
Type=oneshot
RemainAfterExit=yes
WorkingDirectory=/home/maybephilipp/projects/chebur-docker
User=maybephilipp
Group=docker
ExecStartPre=/usr/bin/sleep 3
ExecStart=/snap/bin/docker compose -f chebur.docker-compose.yml up -d
ExecStop=/snap/bin/docker compose -f chebur.docker-compose.yml down
TimeoutStartSec=0
[Install]
WantedBy=multi-user.target
OS: Ubuntu 20.04.4
I tried BindsTo=, PartOf=, Requires= but as I see on the Internet and in practice they don't help in starting my service when snap.docker.dockerd gets started from stopped state.
So my question is: how can I make my service to start when snap kills and then starts docker service?
My second thought is to create cron tab that just does docker compose up -d every 5 mins or less. But it seems very dirty hack:(