How to restart docker for windows process in powershell?

∥☆過路亽.° 提交于 2019-12-07 02:46:31

问题


I want to restart docker for windows in powershell.

just like I can do it with one command in powershell.

May I implement it?

When using Restart-Service *docker*:


回答1:


Kill and restart the docker process:

$processes = Get-Process "*docker desktop*"
if ($processes.Count -gt 0)
{
    $processes[0].Kill()
    $processes[0].WaitForExit()
}
Start-Process "C:\Program Files\Docker\Docker\Docker Desktop.exe"

In the if clause I check if any running docker process has been found. There should never be more than 1 instance of "Docker Desktop" running so you can then kill the first one in the list.

To restart you need to know the full path of the "Docker Desktop.exe" file on your computer.




回答2:


You can user in powershell:

restart-service *docker*

Or int the Docker QuickStart Terminal:

docker-machine restart


来源:https://stackoverflow.com/questions/51760214/how-to-restart-docker-for-windows-process-in-powershell

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