-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create uninstall-docker-ce.ps1 #435
Conversation
Uninstall script for docker ce
I've got a few suggestions on how we could improve the script to be a bit more error-friendly. Please let me know if these are unnecessary since PowerShell scripting is still new to me.
# Docker was installed so check if the service is running
if ((Get-Service -Name $global:DockerServiceName).Status -eq "Running")
{
# Check that no containers are running or warn user
if ($global:GetContainers -match "Up")
{
Write-Output "There are running containers."
$response = Read-Host "Do you want to proceed? (Type 'yes' to continue or 'no' to exit)"
# Stop uninstall if they do not want to proceed
if ($response -ieq "no" -or $response -ieq "n")
{
Write-Output "Aborting uninstall."
return
}
# Continue with uninstall by stopping the service
Stop-Service -Name $global:DockerServiceName
}
}
# Check if Docker was installed before proceeding
if ((Get-Service -Name $global:DockerServiceName -ErrorAction SilentlyContinue) -eq $null)
{
Write-Output "Docker was not installed. Aborting."
return
} # Docker service is not running so unregister dockerd next
if ((Get-Service -Name $global:DockerdServiceName -ErrorAction SilentlyContinue) -ne $null)
{
# Remove dockerd
& dockerd --unregister-service
}
# Check that we successfully removed docker
if ((Get-Service -Name $global:DockerServiceName -ErrorAction SilentlyContinue) -eq $null)
{
Write-Output "Docker-CE was uninstalled."
}
else
{
Write-Output "An error occured and failed to uninstall Docker-CE."
} |
This issue has been open for 30 days with no updates. |
3 similar comments
This issue has been open for 30 days with no updates. |
This issue has been open for 30 days with no updates. |
This issue has been open for 30 days with no updates. |
Uninstall script for docker ce