Goodbye Docker Desktop
Docker in macOS has always been a second-class experience due to the operating system's lack of the required Linux kernel features for native containerization. Because of this, Docker Desktop is the industry-standard way of getting Docker containers running in macOS.
In short, Docker Desktop is an Electron-based GUI application that runs and manages a Linux virtual machine in which containers are actually run.
The application handles:
- The allocation of hardware resources to the VM
- The exposure of a Unix socket for the macOS-native Docker CLI
- The management of volume mappings and networking between macOS and the VM
Despite working well enough for many years the application has continued to bloat, and the Docker organization has begun heavily pushing a subscription model for anything beyond personal use. Maybe it's just me, but I don't want open-source software I rely on to be wrapped in an increasingly blatant monetization layer.
Colima
In the search for alternatives to Docker Desktop (as virtualization is still a requirement) I came across Colima.
Colima's high-level features:
- Intel and M1 Mac support
- Simple CLI interface
- Docker and Containerd support
- Port forwarding
- Volume mounts
- Kubernetes
Colima has done away with the GUI requirement!
Setup
First, uninstall Docker Desktop completely.
I also chose to purge the ~/.docker
directory in service of freshness.
Then install Colima and Docker via Homebrew:
brew install colima docker docker-compose
If needed, install the Docker Buildx plugin:
ARCH=amd64 # change to 'arm64' for m1
VERSION=v0.9.1
curl -LO https://github.com/docker/buildx/releases/download/${VERSION}/buildx-${VERSION}.darwin-${ARCH}
mkdir -p ~/.docker/cli-plugins
mv buildx-${VERSION}.darwin-${ARCH} ~/.docker/cli-plugins/docker-buildx
chmod +x ~/.docker/cli-plugins/docker-buildx
docker buildx version # verify installation
Start Colima:
$ colima start --cpu 2 --memory 4 --disk 60
INFO[0007] starting colima
INFO[0007] runtime: docker
INFO[0007] preparing network ... context=vm
INFO[0007] starting ... context=vm
INFO[0028] provisioning ... context=docker
INFO[0028] starting ... context=docker
INFO[0033] done
Check Colima status:
$ colima status
INFO[0000] colima is running
INFO[0000] arch: aarch64
INFO[0000] runtime: docker
INFO[0000] mountType: sshfs
INFO[0000] socket: unix:///Users/raymond/.colima/default/docker.sock
Lastly, set DOCKER_HOST
to this new Unix socket in ~/.bashrc
or ~/.zshrc
(or other shell profile):
export DOCKER_HOST="unix://${HOME}/.colima/default/docker.sock"
Usage
Just like Docker Desktop, without Docker Desktop.
Pull an image:
$ docker pull caddy
Using default tag: latest
latest: Pulling from library/caddy
9b18e9b68314: Pull complete
480d8737fa00: Pull complete
ee8b251ca0b5: Pull complete
9543d07ca789: Pull complete
88e0320d2afc: Pull complete
Digest: sha256:50743fc6130295e9e8feccd8b2f437d8c472f626bf277dc873734ed98219f44f
Status: Downloaded newer image for caddy:latest
docker.io/library/caddy:latest
Run an image:
$ docker run --rm -d -p 8080:80 caddy
93bb41d7a9db6dc66550c3f994cfffff55fa489b685ac3259bfa1e1de91aec66
Port forwarding!
$ curl http://localhost:8080
<!DOCTYPE html>
<html>
<head>
<title>Caddy works!</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" href="data:,">
<style>
* {
box-sizing: border-box;
padding: 0;
margin: 0;
[...]
It feels good to no longer have Docker Desktop in my menu bar.