Jump to content
skyline7349

Script to restart docker service

8 posts in this topic Last Reply

Recommended Posts

How would i restart docker service via script? Sometimes when i do a force shutdown and power back on. Dockers wont start and say no container. So if I go to settings and disable docker and reenable everything is fine. Is there a way to do this via script?

Share this post


Link to post
3 hours ago, bcjenkins said:

It's pretty easy - 

 


docker restart ${dockerName}

 

No i meant the actual docker service not a docker container

Share this post


Link to post
9 minutes ago, skyline7349 said:

No i meant the actual docker service not a docker container

/etc/rc.d/rc.docker ?
usage /etc/rc.d/rc.docker start|stop|restart|status

 

Share this post


Link to post
On 6.12.2017 at 5:08 PM, bcjenkins said:

/etc/rc.d/rc.docker ?
usage /etc/rc.d/rc.docker start|stop|restart|status

 


Lets say i want to restart all dockers ondce a week, could i just restart the docker service? Will it close the dockers "correct" - soft?!

edit1:

Okay a simple restart didng seemed to work.

 

I have now:
 

#!/bin/bash
/etc/rc.d/rc.docker stop
echo "stopping docker"
/etc/rc.d/rc.docker start
echo "starting docker"

 

Edit2: Okay it worked once, now its not working anymore, any idea? (if i click run script, its just empty)

 

Edited by nuhll

Share this post


Link to post
On 3/15/2018 at 8:38 AM, nuhll said:

Edit2: Okay it worked once, now its not working anymore, any idea? (if i click run script, its just empty)

 

 

Did you get this figured out?  Is what you have working now? 

 

You probably already know that In the scripts sub-directory for the cron you want to run, the script should be in a file simply called script.  First time I tried to setup a script, I created the script in the cron directory (i.e. nightly_reboot) and called it nightly_reboot.cron, which was ignored by user scripts and it created a file in the nightly_reboot folder called script, which was empty and thus ran that instead.

Edited by jeffreywhunter

Share this post


Link to post

I stoped using it because i have problems some contaienrs dont come back :(

Share this post


Link to post

Not sure if people are still interested. But you can do the snippet below to restart all running docker containers. 

 

````

docker restart $(docker ps -q)

````

Share this post


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.