How do I restart Docker for Mac from the terminal?

不打扰是莪最后的温柔 提交于 2019-11-28 19:34:09

问题


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?


回答1:


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.




回答2:


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




回答3:


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


来源:https://stackoverflow.com/questions/40080887/how-do-i-restart-docker-for-mac-from-the-terminal

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!