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.
May I implement it?
When using Restart-Service *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.
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.
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.
In order to use Windows PowerShell commands to manage Docker containers, follow these steps: -Name: Name of repository. -SourceLocation: Source for the repository.
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.
To restart the service open PowerShell and type: When you stop the service and try to use Docker you will get and error.
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
On windows, open Docker desktop and click on the debug icon then restart. You can also consider "reset to factory defaults"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With