问题
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