Docker Community Forums

Share and learn in the Docker community.

Restart Docker from command line


(Tony Pujals) #1

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


Docker beta for Mac hanging on ps
(Dave Tucker) #2

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!


(Tony Pujals) #3

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.


(Dave Wikoff) #4

Would also love some official ways to start/stop the service. I was going to update https://github.com/matryer/bitbar-plugins/blob/e3ebf9ec6f941d29646dff9fe0c6bc6af8f57a56/Dev/Docker/docker-status.1m.sh (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.


(Jforssell) #6

I’ve found that a simple

killall com.docker.osx.hyperkit.linux

will do the trick on macOS.


(Wilon) #7

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

killall Docker && open /Applications/Docker.app

(Barryallard) #8

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


(Deiwin Sarjas) #9

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