Docker Container Auto Restart


Recommended Posts

Hi,

 

Not sure if this has been raised before or if other people have just found ways around it, but could we have some method to selectively (per specific container), have an auto-restart if certain conditions are met?

Such as:

  • RAM usage above a set limit
  • Specific "health-check" port not responding
  • On a cron schedule?

 

I've also noticed some containers fail to start at all sometimes, or a stuck on a startup loop.

In cases like this would there be room to forcibly stop a container and send a notification out if a container is looping or has been forcibly shutdown as a result?

 

My reason for asking is that occasionally I've had to restart Plex Media Server as it's hogging 4-5GB of RAM while idling, and today SABnzbd-VPN was totally unresponsive on the local port and when checking the log noticed it was continually not seeing DNS for PrivateInternetAccess and looping - a forced stop and start resolved it immediately.

 

What's everyone else's experience here? Worth a feature add?

Link to comment

I do restart and backup all docker containers every night with User Scripts. So there's a User Script for each and every docker.

 

I had to move the start of the User Scripts to a different time in the night but that was easy enough (crontab -e).

 

docker stop <containername>

# Backup tasks depending on specific docker containers
# e.g. rsync user content to backup machine
# e.g. cp settings to backup machine (e.g. Plex watch state and settings)
# e.g. dump or export database contents (e.g. MariaDB, SQLite, ...)
# e.g. ...

docker start <containername>

After these scripts are being started every night I no longer experienced any problems.

 

Specific conditions would be cool, but if you start to collect conditions it will become a can of worms IMHO.

 

RAM usage

Port not responding

+ Plex activity from remote users (won't restart and backup Plex if there is streaming activity)

+ Running parity check on remote backup server (won't backup if a parity check is running)

...

 

You get the idea. The possible conditions are nearly endless.

 

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.