Restart Docker from command line

What’s the correct way to restart Docker for the Docker for Mac beta from the command line?


There isn’t a supported way to do this from the command line right now. The best way is to Quit and Re-Open Docker for Mac. There is a pinata restart command but it’s for troubleshooting only and will likely disappear in a future beta.

Thanks for trying out Docker for Mac!

Thanks for the feedback. Good to know about the pinata restart command for the interim. I hope consideration is given to providing official support to start/stop/restart from the command line.


Would also love some official ways to start/stop the service. I was going to update (Bitbar plugin to show containers for docker) but I don’t see official ways documented anywhere.

I found “launchctl start com.docker.helper” to start the service and I’m sure I can find other ways to do it by debugging the process but it would be nice if this was officially documented somewhere.

1 Like

I’ve found that a simple

killall com.docker.osx.hyperkit.linux

will do the trick on macOS.

Kill the app and reopen it. Is the same of restart

killall Docker && open /Applications/

How to control Docker for Mac from the CLI

Stop Docker for Mac gracefully

test -z "$(docker ps -q 2>/dev/null)" && osascript -e 'quit app "Docker"'

Note: Requires all Docker containers in the stopped state

Stop all Docker containers without confirmation (dangerous if running something)

docker ps -q | xargs -L1 docker stop

Note: Assumes all running Docker containers are in a quiesced state

Start Docker gracefully

open --background -a Docker

Note: It may take up to a minute for Docker to fully start


Note: It may take up to a minute for Docker to fully start

I used the following snippet to deal with the issue of knowing when docker is ready to take commands:

while ! docker system info > /dev/null 2>&1; do sleep 1; done

So e.g.:

open --background -a Docker &&
  while ! docker system info > /dev/null 2>&1; do sleep 1; done &&
  docker run busybox

That won’t work on a machine which hasn’t logged into the Mac GUI:

LSOpenURLsWithRole() failed for the application /Applications/ with error -610.

launchctl show docker server, remand docker server name

launchctl list | grep docker

111117   0       com.docker.docker.2388

then stop and start it

launchctl stop com.docker.docker.2388 && launchctl start com.docker.docker.2388

Were you using iTerm2 when you got that error? - I recall getting pretty much the same error shortly after bootstrapping a new Mac on Mojave, and attempting to launch a dashboard from the command-line in iTerm2 ( error -600 in my case…). When a simple test with open http://github.comthrew exactly the same error, but then worked fine in the Terminal app, it was a pretty short trip to Security & Privacy --> Privacy --> adding iTerm2 to “Full Disk Access”, and resolution. Anyway, as mentioned by others in this thread, while it’s more pull than push, using the built-in Terminal app to curl the Github API, and scripts that perhaps leverage some combination of sudo -v/sudo -n, osascript -e and establishing some gating with a few while loops conditioned onsleep 1;, etc. seem like pretty good ideas :slight_smile:

Is there any update to start docker for mac like a daemon on boot without user login ?

Thanks, this worked for me!

This works fine for Pro CML docker start.

FYI, on Apple Silicon, the GUI does this:

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
1 Like