How to Uninstall Docker

Docker's container-based delivery structure for software packages makes a convenient-to-visualize service. Users received it well, and it has notable advantages for resource efficiency compared to VM. Still, Docker isn't always suited to every business or home user's needs. Because its installation can be more involved than most software, uninstalling Docker also can be more multifaceted than the norm slightly. However, users can finish the chore of becoming 'dockless' in minutes, at worst.

Just like you wouldn't uninstall a program while it's running, you also should terminate any Docker containers before removing Docker. Users also may require admin privileges to complete all cleanup steps.

Windows users should type 'PowerShell' in the taskbar's search, right-click it, and choose the 'Run as administrator' option, which provides the necessary elevated privileges. Enter the following commands, one by one, pressing enter each time:

docker swarm leave --force
docker ps --quiet | ForEach-Object {docker stop $_}
docker system prune --volumes --all

The first command leaves swarm mode. The second will stop any containers. Lastly, the final command deletes Docker-related content such as container images, containers, volumes and networks.

However, while these commands remove Docker's 'peripheral' content, they don't delete the Docker program. Non-Windows Server users can delete it by going to Settings, Apps, and scrolling down the program list till Docker appears. Then left-click and choose Uninstall. Windows Server users will require more PowerShell commands. First, if you don't know the Package Provider, input this command:

PS C:\> Get-PackageProvider -Name *Docker*

With that information, input the following commands:

Uninstall-Package -Name docker -ProviderName DockerMsftProvider
Uninstall-Module -Name DockerMsftProvider

You also should erase any remaining network or miscellaneous program data. The following PowerShell commands will do that for you:

Get-HNSNetwork | Remove-HNSNetwork
Get-ContainerNetwork | Remove-ContainerNetwork
Remove-Item "C:\ProgramData\Docker" -Recurse

Users who don't have any other programs with Hyper-Virtualization or Hyper-V features also may disable that feature for optimization. In Windows 10, the option is in the Control Panel. Open it, go to Programs, and then 'Programs and Features,' and 'Turn Windows features on or off.' The 'Containers' and 'Hyper-V' features should be near the top of the list. Click them to enable or disable them.

Restarting the computer will finalize all changes. Windows Server users should do so with this PowerShell command:

Restart-Computer -Force

For all of the niceties of uninstalling Docker from a Windows Server environment, macOS users have it much more laidback than their Windows counterparts. Experts recommend that users take advantage of the built-in uninstall feature in Docker. Go to the Preferences section on Docker's UI, and click either the Insect or Bomb icon (depending on the version), which opens the troubleshooting area. Click the Uninstall bottom near the bottom of the list. This method also removes related components like containers and images automatically.

Some users also prefer uninstalling Docker in macOS with third-party utilities like Homebrew Cask. Although this method works similarly to the PowerShell equivalent on Windows, it requires a third-party program. Experts discourage it on these grounds for average users.