Docker Start/Stop on Timer


22 posts in this topic Last Reply

Recommended Posts

Don't think it's currently possible, but it would be nice to be able to start and / or stop a docker on a schedule. For example, only have download type dockers run overnight, or media servers running on evenings/weekends.  Likely not that simple to get a full featured scheduler in there, but might be nice.

Link to post

Don't think it's currently possible, but it would be nice to be able to start and / or stop a docker on a schedule. For example, only have download type dockers run overnight, or media servers running on evenings/weekends.  Likely not that simple to get a full featured scheduler in there, but might be nice.

Use user.scripts plugin

 

Scripts would be something like

docker stop nameOfContainer

and

docker start nameOfContainer

Link to post
  • 3 months later...
On 1/15/2017 at 11:51 AM, Squid said:

Use user.scripts plugin

 

Scripts would be something like

 


docker stop nameOfContainer
 

 

and


docker start nameOfContainer
 

 

 

But having something built in for idiots like me would be helpful!

Link to post

I wrote this script that I tell user.scripts to fire off every morning at 7AM-11AM to back up some stuff from my Mac

#!/bin/bash
#Start Docker
docker start resilio-sync

#Delay before issuing Stop
sleep 4h

#Stop Docker
docker stop resilio-sync

 

Link to post
On 5/11/2017 at 6:23 AM, kizer said:

I wrote this script that I tell user.scripts to fire off every morning at 7AM-11AM to back up some stuff from my Mac


#!/bin/bash
#Start Docker
docker start resilio-sync

#Delay before issuing Stop
sleep 4h

#Stop Docker
docker stop resilio-sync

 

 

One could also use the cron expression feature of user.plugins for more customization options.

Link to post
  • 2 years later...
  • 4 months later...
6 hours ago, halogen55 said:

HI Team, why are you stopping your dockers? When a docker process completes the conainer should stop itself.

Some dockers could - and do - run processes 24/7.  If there is no scheduling built into that docker you might not want it running all the time.  For example...

  • You could have something like a Handbrake docker converting all videos in a watched folder to a common format.  Files could go into the watched folder at any time.  This can be system intensive, so you might only want it running overnight when you're not using it for watching movies
  • You might be running Boinc / Folding @ Home - deliberately very processor intensive - and you only want running when you're doing nothing else.  Slightly tenuous, since at least Boinc has its own built-in scheduler
  • You might have torrents - or similar - running, and you don't want to saturate your internet connection during the times you're likely to be needing it (streaming / gaming)
  • There might be something - like a game/media server - that you only want running at certain times of the day for the kids

A few examples, there are perhaps more.  There are dockers I only start when I want to use them, and some that I sometimes put on a schedule.

Link to post
  • 4 weeks later...
  • 3 weeks later...
  • 2 months later...
  • 4 months later...
  • 2 months later...
  • 3 weeks later...

Since I do not know of any specific plans to add this feature to unRaid I have added a section here on what can be done in the meantime to easily set up such a schedule (in the Docker section of the online documentation that can be accessed via the Manual link at the bottom of the unRaid GUI). 

 

I would be interested to know if this is considered sufficient in the short term or more detail is needed?

 

 

Link to post
16 minutes ago, itimpi said:

I would be interested to know if this is considered sufficient in the short term or more detail is needed?

Looks good to me.  Would "docker start <name of container>" work, rather than docker run...?

 

I was thinking of writing a generic user script which ran every 5 minutes (say).  At the top you fill in an array of all the start/stop events you want to happen, each entry having container name, start time and stop time (or array of time ranges).  Then when the script was run it would decide whether it needed to do anything by comparing the current state of a docker against its schedule.  Puts it all into a single script then, but prevents the user from overriding the schedule by manual start/stop.  Parked it until I could think of better logic.

Link to post
29 minutes ago, jonathanm said:

That's how I've always done it.

 

I'll amend the bit I added to the documentation to mention that you can use 'start' if you have already created the container, and use run if you want to either redownload the container or change a setting.   I think for practical purposes that is the difference?  I perhaps also need to explain how the image name is set up and used?

Link to post

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.