Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to restart docker for windows process in powershell?

I want to restart docker for windows (now known as Docker Desktop) in powershell.

I would like to do it with one command in PowerShell.

enter image description here

May I implement it?

When using Restart-Service *docker*:

enter image description here

like image 322
pwxcoo Avatar asked Aug 09 '18 06:08

pwxcoo


People also ask

How do I restart my docker?

To do this, you must restart the docker service. If you edit the /etc/sysconfig/docker configuration file while the docker service is running, you must restart the service to make the changes take effect.

How do I force restart a docker container?

Using --restart unless-stopped tells Docker to always restart the command, no matter what the exit code of the command was. This way, you can have your application check its health, and if necessary use exit(1) or something similar to shutdown.

How do I restart a docker service in PowerShell?

To restart the service open PowerShell and type: Restart-service docker. You can also use: start-service docker. To stop the service type: Stop-service docker. When you stop the service and try to use Docker you will get and error.

How to use PowerShell commands to manage Docker containers?

In order to use Windows PowerShell commands to manage Docker containers, follow these steps: -Name: Name of repository. -SourceLocation: Source for the repository.

How to install Docker on Windows 10 desktop or Windows Server?

Note: Once the Chocolatey is on your system, close the Powershell and reopen it as Admin. Now, everything is ready on Powershell and we can use the Choco command to install Docker on Windows 10 Desktop or Windows Server OS. When the above command asks for your permission to install the packages, allow it by typing A and hitting the Enter key.

How to restart the service using PowerShell?

To restart the service open PowerShell and type: When you stop the service and try to use Docker you will get and error.


3 Answers

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.

like image 155
eddex Avatar answered Oct 20 '22 16:10

eddex


You can user in powershell:

restart-service *docker*

Or int the Docker QuickStart Terminal:

docker-machine restart
like image 8
mlameiras Avatar answered Oct 20 '22 16:10

mlameiras


On windows, open Docker desktop and click on the debug icon then restart. You can also consider "reset to factory defaults"

enter image description here

like image 5
Piaget Hadzizi Avatar answered Oct 20 '22 16:10

Piaget Hadzizi