rouan
rouan

Reputation: 7219

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?

Upvotes: 111

Views: 109419

Answers (5)

Isanderthul
Isanderthul

Reputation: 66

This is what I am using (source):

alias docker_restart="curl -X POST -H 'Content-Type: application/json' -d '{ \"openContainerView\": true }' -kiv --unix-socket ~/Library/Containers/com.docker.docker/Data/backend.sock http://localhost/engine/restart"

Upvotes: 1

Ahsan
Ahsan

Reputation: 4154

The following command worked for me:

killall Docker && open /Applications/Docker.app

Upvotes: 48

Dave Dunn
Dave Dunn

Reputation: 211

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 ""

Upvotes: 21

BrDaHa
BrDaHa

Reputation: 5760

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.

Upvotes: 161

guilleHeuer
guilleHeuer

Reputation: 215

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

Upvotes: 12

Related Questions