In this article, I am going to continue on with my Docker journey and walk through how to uninstall Docker on both Windows 10 and Windows Server 2016. It is always good to get the basics down first before moving on to the good stuff.

Prepare for Docker Removal

It is a good idea to make sure you have no running containers before you remove Docker. This can be done with the following commands in an Elevated PowerShell window.

# Leave swarm mode (this will automatically stop and remove services and overlay networks)
Docker swarm leave --force
# Stop all running containers
docker ps --quiet | ForEach-Object {docker stop $_}

Now that you left the Swarm and stopped all running containers its good practice to remove all containers, container images, networks and volumes. This can be done using the following command in the Elevated PowerShell window.

docker system prune --volumes --all

Now that you have cleaned up all of your Docker containers you can safely uninstall Docker.

Uninstall Docker

Uninstall from Windows 10

To uninstall Docker from Windows 10 navigate to Settings and then Apps

Locate Docker for Windows and click it.

Now click Uninstall follow the uninstall wizard.

You have now uninstalled Docker from Windows 10. Click the X atop right to close the uninstaller.

Uninstall Docker from Windows Server 2016

To uninstall Docker from Windows Server 2016 you will need to use an Elevated PowerShell window. First, we need to find the name of the Package Provider. This can be done using the following PowerShell command.

Get-PackageProvider -Name *Docker*

Now we can use the below command to uninstall the packages. You will see in the above image, that we are using the DockerProvider provider. If yours is different change the below script to reflect your setting.

Uninstall-Package -Name docker -ProviderName DockerProvider
Uninstall-Module -Name DockerProvider

Clean up the Docker leftovers

To clean up what is left of Docker (Dockers default network and some system files) on both Windows Server 2016 and Windows 10. You have to use an Elevated PowerShell window again.

To clean up the Network you can use the following PowerShell command.

Get-HNSNetwork | Remove-HNSNetwork

To clean up the system data you can use the following PowerShell command.

Remove-Item "C:\ProgramData\Docker" -Recurse

You have now uninstalled Docker from your system.

I hope you found this article helpful if you have any questions please leave a comment below.

Pixel Robots.

I’m Richard Hooper aka Pixel Robots. I started this blog in 2016 for a couple reasons. The first reason was basically just a place for me to store my step by step guides, troubleshooting guides and just plain ideas about being a sysadmin. The second reason was to share what I have learned and found out with other people like me. Hopefully, you can find something useful on the site.

Leave a Reply

Your email address will not be published. Required fields are marked *