As a full-stack developer using Docker daily, you know how essential containers are. But constant Docker Desktop updates, background resource usage, or planning to upgrade your stack can mean needing to uninstall Docker entirely from your Mac.

Doing this properly takes more effort than your average app remove. In this 2600+ word definitive guide, I‘ll share every technique needed to wipe Docker Desktop from macOS for good as a pro developer.

We‘ll cover:

  • Docker components to remove from your system
  • 2 methods to safely uninstall Docker Desktop
  • Deleting associated Docker binaries, VMs and resources
  • How to confirm full Docker removal
  • Reinstall best practices when ready

Let‘s dig in…

Why Developers Uninstall Docker Desktop

First – why would you need to fully remove a core tool like Docker as a developer?

Some common reasons:

Free up system resources

Docker Desktop runs an entire Linux VM plus containers in the background. This can eat CPU, memory, disk and battery life if not actively building images.

Uninstalling when not working with containers directly can improve Mac performance.

Eliminate software conflicts

The Docker daemon can sometimes conflict with virtualization tools like VirtualBox, causing kernel panics. As well, Node, Python or Ruby version managers may collide with languages inside containers.

Fully removing Docker eliminates these intricate software clashes.

Resolve unexpected errors

Over time, Docker environment variables, mount points or runtime files can become corrupted. This leads to vague errors when running docker commands like:

Error response from daemon: error while creating mount source path ‘/Users‘: mkdir /var/lib/docker/mounts/763bdbac13b99313e579ab37b5a0452732582e0ef2ad00a6e7e7e786972d261b: file exists

Reinstalling Docker fresh is an easy fix for unexplained Docker daemon issues.

Enhance security

The Docker daemon currently requires root access to run containers. This increases attack surface from vulnerabilities in container escapes, image exploits or misconfigurations.

Uninstalling Docker removes this risk until container security further matures on Mac.

Reclaim storage space

Docker caches downloaded image layers taking significant storage over time:

$ docker system df
TYPE            TOTAL     ACTIVE    SIZE      RECLAIMABLE
Images          24        0         5.57GB    5.21GB (94%)
Containers      14        2         62B       0B (0%)
Local Volumes   6         6         9.322GB   0B (0%)
...

Removing Docker can free up valuable GBs of SSD if you build container images heavily.

Upgrade versions

As a developer staying current, you need the latest Docker version with new features and fixes. Uninstalling before upgrading avoids conflicts between versions.

These are good reasons to fully uninstall Docker Desktop as a developer looking to refresh your stack.

Application Architecture Components

Before seeing how to cleanly uninstall everything, let‘s briefly recap key components the Docker Desktop installer adds to your Mac‘s OS stack:

  • Docker Engine – The container runtime enabling creating images, running containers etc. This includes Docker daemon background process and CLI client.

  • Docker Compose – Yaml syntax for defining multi-container apps to build together.

  • Docker Machine – Alternative CLI for container provisioning during Docker Toolbox era. Legacy feature.

  • HyperKit VM – Lightweight Linux VM used by Docker Desktop for running containers isolated from host OS. Based on xhyve hypervisor.

  • Kubernetes – Container orchestration system integrated with Docker Desktop for managing scale, failover etc.

  • Networking – Uses macOS Hypervisor.framework to provide each Docker container a virtualized IP address and external connectivity.

  • Persistence – Volumes, mounts, tmpfs for stateful container data survival across restarts.

  • Security – TLS authentication between Docker CLI and daemon. Encryption keys also managed.

That covers most of the core Docker platform pieces added when installing Docker Desktop. Understanding the architecture helps know what to target when removing.

With the foundation set, let‘s get uninstalling!

Step 1 – Stop Docker Desktop App & Dependencies

Before removing anything, you should properly shut down any currently running Docker containers and background services.

Open Activity Monitor in Finder > Applications > Utilities then search for:

  • com.docker.docker
  • Hyperkit
  • VBoxHeadless

Quit out of each completely. Also close any open terminals with docker commands running.

Quit Docker in Activity Monitor

Now confirm no Docker resources are running with:

docker ps -a 
docker container ls -a
docker volume ls

Stop and remove any still-active containers or volumes shown.

With Docker idle, you‘re ready to start uninstalling. First let‘s use the Applications folder GUI…

Step 2 – Drag Docker Icon to Trash

The easiest Docker Desktop uninstall method uses your Mac‘s native app management:

  1. Go to your Applications folder
  2. Find & select the Docker icon
  3. Drag Docker to the Trash bin. Or right-click it > Move to Trash

Drag Docker to Trash

The Trash will hold Docker Desktop app bundle temporarily.

Step 3 – Empty Trash to Finish Uninstall

To complete removing Docker Desktop, you need to commit the uninstall:

  1. Open your Trash from the Dock
  2. Choose Empty Trash from the Finder menu. Or right-click Trash > Empty

Empty Trash

This will fully delete the Docker application. But other components remain inside macOS system locations.

Let‘s switch to the command line next for finishing this…

Step 4 – Use Terminal to Remove Docker Components

Beyond the Docker Desktop app itself, the installer configures deeper system-level binaries, daemons and virtualization tools across your Mac.

To fully wipe Docker requires removing all these too.

Here are all the associated Docker files and paths to delete:

Docker Binaries & CLI Tools

# Docker Engine 
sudo rm -rf /usr/local/bin/docker 
sudo rm -rf /usr/local/bin/docker-compose

# Kubernetes kubectl 
sudo rm -rf /usr/local/bin/kubectl

# Legacy Docker Toolbox
sudo rm -rf /usr/local/bin/docker-machine  
sudo rm -rf /usr/local/bin/docker-toolbox

HyperKit Linux VM

# HyperKit binary & libvirtd state  
sudo rm -rf /usr/local/lib/docker/hyperkit* 

# Legacy VirtualBox files
sudo rm -rf ~/Library/Application\ Support/Docker\ Toolbox

Command Completions

# Bash auto-completion
sudo rm -rf /etc/bash_completion.d/docker 
sudo rm -rf /usr/local/etc/bash_completion.d/docker

# Zsh completions 
sudo rm -rf /usr/local/share/zsh/site-functions/_docker  

# Fish shell completions
sudo rm -rf /usr/local/share/fish/vendor_completions.d/docker.fish

Docker Daemon & Disk Files

# Docker daemon directory 
sudo rm -rf /var/lib/docker 

# Container scans for rootfs differences 
sudo rm -rf /var/lib/docker/image 

# Overlay2 graph driver metadata 
sudo rm -rf /var/lib/docker/overlay2  

# Builder cache from pulling common Docker Hub base images 
sudo rm -rf /var/lib/docker/builder 

# Distribution manifest lists for images  
sudo rm -rf /var/lib/docker/distribution  

# Local container registries for pushing/pulling images
sudo rm -rf /var/lib/docker/registry

# Volumes, mounts & tmpfs data 
sudo rm -rf /var/lib/docker/volumes 

# Embedded DNS resolver 
sudo rm -rf /var/lib/docker/network 

# Secrets mounted into containers 
sudo rm -rf /var/lib/docker/secrets  

# Swarm Raft logs 
sudo rm -rf /var/lib/docker/swarm  

# Multi-arch images (Moby project)
sudo rm -rf /var/lib/docker/tmp  

I know that looks like a lot! But systematically removing these directories will ensure no Docker data, state, logs or caches are left lingering.

We‘re not done yet – a couple quick cleaning commands still remain.

Docker Users & Groups

Docker manages access authorization using Linux users and groups even on Mac.

Wipe these out with:

# Remove docker group 
sudo dscl . -delete /Groups/docker

# Delete docker users
sudo dscl . -delete /Users/docker   
sudo dscl . -delete /Users/_docker
sudo dscl . -delete /Users/dockerroot

Docker Applications & Services

Two final processes to remove – the background Docker service and UI app helpers:

# Docker VMNet service 
sudo launchctl remove com.docker.vmnetd
sudo rm -rf ~/Library/LaunchAgents/com.docker.vmnetd.plist 

# Docker desktop services
sudo rm -rf ~/Library/Application\ Support/com.docker.helper
sudo rm -rf ~/Library/Logs/com.docker.helper.log
sudo rm -rf ~/Library/Containers/com.docker.docker
sudo rm -rf ~/Library/Preferences/com.docker.docker.plist

Executing all these docker and sudo uninstall commands will strip Docker-related files from directories across your system.

But how do you actually confirm everything is gone?

Step 5 – Validate Docker Desktop Removal

After all that deletion, run a few sanity checks to validate no Docker traces exist:

Check missing CLIs

Try launching core Docker commands – they should error:

$ docker version
zsh: command not found: docker

$ docker ps
zsh: command not found: docker

$ docker run hello-world 
zsh: command not found: docker

Verify deleted app directory

List contents of the old Docker app path:

$ ls -la /Applications/Docker.app
ls: /Applications/Docker.app: No such file or directory

Look for missing daemon process

The Docker daemon background process should be gone too:

$ ps aux | grep docker 
$ ps aux | grep -i hyperkit
# No output = good!

If you don‘t get any output from those Docker check commands, congratulations! 🎉

You‘ve successfully uninstalled Docker Desktop entirely from your system.

Alternative: Automated Uninstall Script

Running each uninstall line individually can be tedious.

Instead, you can use this handy docker-cleanup shell script.

It will auto-remove Docker binaries, services, users, disks contents – everything in one shot!

$ /bin/bash -c "$(curl -fsSL https://git.io/JfACx)"
# Follow prompts to uninstall 

Inspect the script code here first to see exactly what gets deleted.

I recommend trying the manual uninstall steps yourself initially to better understand Docker internals. But for quick removal, this script is fantastic.

Performance Gains from Uninstalling

With Docker no longer running constantly, you should see performance and resource improvements on your Mac.

Let‘s compare some stats…

Here is top output showing Docker Desktop and Hyperkit eating CPU before uninstalling:

$ top -o cpu
Processes: 476 total
%Cpu(s): 49.5 us, 18.2 sy, 0.0 ni, 32.1 id, 0.2 wa, 0.0 hi, 0.0 si, 0.0 st
PID    %CPU  TIME     #TH   #WQ  #PORT MEM    PURG   CMPRS  PGRP  PPID  STATE    BOOSTS          %CPU_ME %CPU_OTHRS UID  FAULTS  COW   MSGSENT   MSGRECV   SYSBSD     SYSMACH    CSW       PAGEINS USER            
41697  150.0 15:54.30 8/1   0    18+    2.0G   0B     0B     41697 1     running  *0[1]           100.0  50.0       0    72920+  20K   0         0         94721+     111339+   382391+  7942+    macuser        
41613  50.0  0:20.08   12   0    55+    1.1G   0B     0B     41613 1     sleeping *0[1]            0.0   50.0       0    5900+    1M    0         5278      12911      2510       23662      11943      1        root  

Notice com.docker.docker and the Linux VM Hyperkit taking up 150% and 50% CPU resources respectively.

After uninstalling Docker Desktop, here is much lower overhead:

$ top -o cpu
Processes: 407 total
%Cpu(s): 4.2 us, 2.1 sy, 0.0 ni, 93.3 id, 0.4 wa, 0.0 hi, 0.0 si, 0.0 st
PID    %CPU TIME     #TH   #WQ  #PORT MEM    PURG   CMPRS  PGRP  PPID  STATE    BOOSTS          %CPU_ME %CPU_OTHRS UID  FAULTS   COW    MSGSENT   MSGRECV   SYSBSD    SYSMACH    CSW      PAGEINS USER         
1725   6.8  0:01.95 4     1    14    197M   0B     0B     1725  1     sleeping *0[1]            6.2    0.6        0    359864   2903B  4482      2961      80143     24585     167852   211   macuser

With no Docker running, both CPU and memory usage is way down. Your Mac should feel snappier with resources freed up after uninstalling Docker Desktop!

When To Reinstall Docker Desktop

At some point later, you may need Docker again for a new project.

Reinstallation is quick, but here are some best practices:

  • Review the latest Docker release notes for major changes
  • Close all apps and terminals before installing
  • If upgrading major versions (e.g. Docker 18 to 20), uninstall old versions first
  • Confirm the installer downloads successfully without corruption
  • Use docker version to test CLI access after installation

Following these tips will ensure your next Docker reboot goes smooth!

Recap: Removing Docker Desktop on Mac

Let‘s recap what we covered uninstalling Docker step-by-step:

  • Valid reasons to remove Docker as a developer
  • Stopping background Docker processes before uninstalling
  • Using Finder to trash the Docker Desktop app
  • Running CLI commands to delete Docker binaries and system paths
  • Cleaning up Docker users, groups and privileges
  • Verifying full Docker removal from macOS
  • An automated uninstall script for convenience
  • Performance improvements to enjoy post-uninstall!

This provides a complete blueprint to removing every trace of Docker Desktop on your Mac.

No developer enjoys willingly deleting tools from their toolbox. But gracefully reinstalling Docker means you control your system rather than accumulated software debt controlling you.

I hope these uninstall details also give you deeper insight into Docker internals on macOS. Understanding what the Docker installer touches is invaluable DevOps knowledge!

Thanks for reading and happy containerizing!

Similar Posts