2

I have a problematic docker container on my media server (plex/xTeVe running on Synology NAS) that likes to stop responding to requests but is otherwise healthy (doesn't fail docker-compose healthchecks).

Is there a way to develop a trigger that can automatically restart this container? I have a webserver and am comfortable hosting other home automation tools to make this possible. I just haven't found a viable option yet. Bonus points if this can be spouse-friendly so when another family member runs into a media server problem, they can have a simple trigger to use to restart the container without having to understand the technical aspects (simple webpage, physical home automation button, Alexa command, etc.).

I'd love to hear any and all suggestions! Thanks!

astorm
  • 21
  • 1
  • 2
    You could configure a ```cron``` job on host machine where the container is running and periodically check the service which usually stop responding and send a restart command. This can be either done with bash or python (e.g. ```docker-py```) script. – m19v Sep 09 '22 at 23:55

1 Answers1

0

Use cron to periodically run a checking/monitoring shell script and react to detected conditions/events.

Modern media servers normally serve some playlist thru http, thus, to detect availability, you may simply use curl to check server response for a certain URL with small timeout then decide to do a 'docker restart container_name' if you got no or bad response.

Notes:

  • You don't need a loop and an open session because corn does that for you.
  • Use vi my_script.sh to create your script
  • Use crontab -e to add your script to cron table
Bahram Ardalan
  • 280
  • 3
  • 11