Today is the deadline for the license changes to Docker Desktop for Mac and Windows. This means that if you are employed at a company with more than 250 employees or your company makes more than $10m you need to start paying a subscription to continue using Docker Desktop.
I don’t need all the bells and whistles that come with a Docker subscription, I just need to be able to run Docker containers on my Mac. Docker Desktop brings a full GUI and Kubernetes support that I just don’t use. I prefer the command line and I use kind for Kubernetes.
So today I’m uninstalling Docker Desktop and switching to Colima.
If you’re interested in why I chose Colima check out my full post on exploring alternatives.
What is Colima?
Colima is Docker for Mac tool built on Lima. Lima is a virtual machine tool for MacOS with automatic file sharing and port forwarding. Using Lima feels a lot like using WSL on Windows.
Lima launches Linux virtual machines with automatic file sharing and port forwarding (similar to WSL2), and containerd.
Lima can be considered as a some sort of unofficial “containerd for Mac”.
Colima builds on that foundation to run a VM with Docker installed and it also configures your local Docker context for you.
Removing Docker Desktop
First things first I’m going to quit Docker Desktop and drag it to the trash.
Next we also need to remove the VM image that Docker Desktop created, this can be pretty large so we don’t want to miss deleting it.
$ du -sh ~/Library/Containers/com.docker.docker/ 52G /Users/jtomlinson/Library/Containers/com.docker.docker/ $ rm -rf ~/Library/Containers/com.docker.docker/
We should also remove
~/.docker/config.json so that we start with a fresh configuration that doesn’t depend on binaries in the Docker Desktop app.
$ rm ~/.docker/config.json
Docker Desktop provided us with useful command line tools such as
docker and kept them up to date for us. So we need to grab those from another source. Let’s install everything from Homebrew.
brew install docker docker-compose kubectl kubectx
This gives us the command line tools, but not a running Docker service. We can see that by running
$ docker ps Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
Next to start our Docker service we need to install and start Colima.
$ brew install docker colima $ colima start INFO starting colima INFO creating and starting ... context=vm INFO provisioning ... context=docker INFO restarting VM to complete setup ... context=docker INFO stopping ... context=vm INFO starting ... context=vm INFO starting ... context=docker INFO waiting for startup to complete ... context=docker INFO done
That’s it! Colima is now running Docker in a Lima VM and it created a new
docker context and switched to it so we can use the
docker CLI straight away.
Let’s run an nginx container to check everything works as expected.
docker run --rm -p 8080:80 nginx
I can head to my browser and check that it works.
Hooray! That worked, our container started and our ports even mapped correctly.
Docker Desktop also optionally provides Kubernetes so let’s start that too. Minikube and kind are popular choices for running Kubernetes locally for development and both just require Docker so should work fine with Colima.
My preference is
kind, but sadly the current version (
v0.11.1) contains a bug that prevents it from working with
colima. This has been fixed upstream but is yet to be released, so first we need to install the latest development version of
brew unlink kind # Unlink it if we already have it installed brew install kind --HEAD
Now we can create our
$ kind create cluster --name test Creating cluster "test" ... ✓ Ensuring node image (kindest/node:v1.23.1) 🖼 ✓ Preparing nodes 📦 ✓ Writing configuration 📜 ✓ Starting control-plane 🕹️ ✓ Installing CNI 🔌 ✓ Installing StorageClass 💾 Set kubectl context to "kind-test" You can now use your cluster with: kubectl cluster-info --context kind-test Thanks for using kind! 😊
Hooray now we have a
kind cluster running in a Docker container inside Colima. Let’s use
kubectl to check everything is up and running.
$ kubectl get all --context kind-test -A NAMESPACE NAME READY STATUS RESTARTS AGE kube-system pod/coredns-64897985d-ksnlj 1/1 Running 0 15s kube-system pod/coredns-64897985d-np59l 1/1 Running 0 15s kube-system pod/etcd-test-control-plane 1/1 Running 0 27s kube-system pod/kindnet-2zfr5 1/1 Running 0 15s kube-system pod/kube-apiserver-test-control-plane 1/1 Running 0 27s kube-system pod/kube-controller-manager-test-control-plane 1/1 Running 0 27s kube-system pod/kube-proxy-gjqss 1/1 Running 0 15s kube-system pod/kube-scheduler-test-control-plane 1/1 Running 0 27s local-path-storage pod/local-path-provisioner-5bb5788f44-d8ww5 1/1 Running 0 15s NAMESPACE NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE default service/kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 30s kube-system service/kube-dns ClusterIP 10.96.0.10 <none> 53/UDP,53/TCP,9153/TCP 28s NAMESPACE NAME DESIRED CURRENT READY UP-TO-DATE AVAILABLE NODE SELECTOR AGE kube-system daemonset.apps/kindnet 1 1 1 1 1 <none> 21s kube-system daemonset.apps/kube-proxy 1 1 1 1 1 kubernetes.io/os=linux 27s NAMESPACE NAME READY UP-TO-DATE AVAILABLE AGE kube-system deployment.apps/coredns 2/2 2 2 28s local-path-storage deployment.apps/local-path-provisioner 1/1 1 1 19s NAMESPACE NAME DESIRED CURRENT READY AGE kube-system replicaset.apps/coredns-64897985d 2 2 2 16s local-path-storage replicaset.apps/local-path-provisioner-5bb5788f44 1 1 1 16s
Managing Colima’s resource usage
Docker Desktop also provides a handy way to configure how much CPU, memory and storage Docker can use on your Mac. We can do this with Colima too via the
colima command line.
It seems that by default the VM has 2 CPU cores, 2GiB of memory and 60Gib of storage. We can modify the CPU and memory by stopping and starting Colima.
$ colima stop INFO stopping colima INFO stopping ... context=docker INFO stopping ... context=vm INFO done $ colima start --cpu 4 --memory 8 INFO stopping colima INFO stopping ... context=docker INFO stopping ... context=vm INFO done INFO using docker runtime INFO starting colima INFO starting ... context=vm INFO provisioning ... context=docker INFO starting ... context=docker INFO waiting for startup to complete ... context=docker INFO done
However if we want to modify the storage allocation we need to delete the VM and recreate it, which is straight forward but means we will lose our container and images including our
$ colima stop INFO stopping colima INFO stopping ... context=docker INFO stopping ... context=vm INFO done $ colima delete are you sure you want to delete colima and all settings? [y/N] y INFO deleting colima INFO deleting ... context=vm INFO done $ colima start --cpu 4 --memory 8 --disk 100 INFO starting colima INFO creating and starting ... context=vm INFO provisioning ... context=docker INFO restarting VM to complete setup ... context=docker INFO stopping ... context=vm INFO starting ... context=vm INFO starting ... context=docker INFO waiting for startup to complete ... context=docker INFO done
That’s it, Docker Desktop for Mac is gone and we now have a quick and simple replacement thanks to Colima.
It is worth noting that Colima doesn’t auto start when we turn on our machine so we need to remember to run
colima start after each reboot.
If you ever want to switch back you can also just reinstall Docker Desktop and switch your Docker context back.
docker context use default
You can even run them side by side if you want to while you are evaluating.