0

Whenever a container is stopped, restarted or deleted, I would like it to execute a bash command for the host machine.

E.g. fusermount -u /path/to/folder

But I have not figured out a way to do this in the compose file. What I have in mind is similar to the Exec STOP function of systemd too.

Asmodean
  • 59
  • 1
  • 1
  • 6
  • Your Docker instance would have to be configured to detect and handle the `SIGTERM` signal. – ceejayoz Jun 14 '22 at 16:04
  • @ceejayoz example compose file? – Asmodean Jun 14 '22 at 16:16
  • It wouldn't be something in the compose file. (You can configure the signal sent using `stop_signal`, and the length of time it's given to complete its shutdown tasks via `stop_grace_period`, but it's up to you and your application to decide what to do when the process receives a `SIGTERM`.) – ceejayoz Jun 14 '22 at 16:18
  • (As an example, here's how Go handles signals: https://gobyexample.com/signals) – ceejayoz Jun 14 '22 at 16:21

0 Answers0