A container bind-mounted to a USB disk that drops keeps holding the dead storage and spits errors for hours. You can tie the service to the mount: mount goes down, service goes down; mount comes back, service comes back.
# myapp.service
[Unit]
RequiresMountsFor=/media/external
BindsTo=media-external.mount
After=media-external.mount
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/bin/docker compose up -d
ExecStop=/usr/bin/docker compose down
BindsTo takes the service down automatically when the mount unit goes inactive
— the ExecStop runs a clean down instead of leaving everything in I/O error.
For the other direction (mounted → start the service), the mount unit needs a
Wants=myapp.service.
The mount unit’s name comes from the path: /media/external becomes
media-external.mount. Check with systemctl list-units --type=mount.