Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Crontab won't restart Docker container

I have a container that runs under a Root account which I can start using:

docker start containername

and I want crontab to start it, so as root I used

crontab -e

and set an entry like this:

* * * * * /usr/bin/docker start containername

but it won't work. I also tried

* * * * * root /usr/bin/docker start containername

with no luck.

Anyone has a clue on how I can make this work?

like image 932
user3472897 Avatar asked Oct 17 '22 05:10

user3472897


1 Answers

I did it without any problems as follows:

$ crontab -e

then I set a restart for a container every 5 minutes:

*/5 * * * * docker restart <containername>
like image 161
Benyamin Jafari Avatar answered Oct 19 '22 19:10

Benyamin Jafari