How to restart docker for windows process in powershell? How to restart docker for windows process in powershell? powershell powershell

How to restart docker for windows process in powershell?


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.


You can user in powershell:

restart-service *docker*

Or int the Docker QuickStart Terminal:

docker-machine restart


Similar to Sebastian L's comment above, but slightly cleaner & faster if you know whether you are currently running Linux or Windows containers.

If running Linux Containers

    Stop-Service *docker*            Start-Service *docker*    &$Env:ProgramFiles\Docker\Docker\DockerCli.exe -SwitchLinuxEngine

If running Windows Containers

    Stop-Service *docker*            Start-Service *docker*    &$Env:ProgramFiles\Docker\Docker\DockerCli.exe -SwitchWindowsEngine

-SwitchDaemon toggles from one to the other (Linux to Windows or Windows to Linux) which is why you have to do it twice.