Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I restart Docker for Mac from the terminal?

Docker for Mac has a neat little 'restart' button in the dropdown from the whale icon in the menu bar.

I'd like to be able to restart Docker for Mac from the terminal, though. What command would I need to run?

like image 554
rouan Avatar asked Oct 17 '16 07:10

rouan


People also ask

How do I restart my Docker?

To do this, you must restart the docker service. If you edit the /etc/sysconfig/docker configuration file while the docker service is running, you must restart the service to make the changes take effect.

Can we restart Docker container?

Docker provides restart policies to control whether your containers start automatically when they exit, or when Docker restarts. Restart policies ensure that linked containers are started in the correct order. Docker recommends that you use restart policies, and avoid using process managers to start containers.


4 Answers

Specifically for Docker for Mac, because it's a "GUI" app, there's a workaround:

osascript -e 'quit app "Docker"'

Since you'd want to restart, here's the way to open it from the command line:

open -a Docker

There's probably a more symmetrical command to open using osascript, but the open command seems more common than the osascript one.

like image 104
BrDaHa Avatar answered Sep 23 '22 21:09

BrDaHa


The following command worked for me:

killall Docker && open /Applications/Docker.app 
like image 37
Raptor Avatar answered Sep 25 '22 21:09

Raptor


Docker takes a while to initialize.

osascript -e 'quit app "Docker"'; open -a Docker ; while [ -z "$(docker info 2> /dev/null )" ]; do printf "."; sleep 1; done; echo ""
like image 42
Dave Dunn Avatar answered Sep 26 '22 21:09

Dave Dunn


Looks like there is no way to perform this.

I found an official answer for the same question in:

https://forums.docker.com/t/restart-docker-from-command-line/9420/2

Hope they include this feature soon.

Regards

like image 42
guilleHeuer Avatar answered Sep 25 '22 21:09

guilleHeuer