Update — “Docker” and Kubernetes on macOS: A Setup for 2022

3 min readDec 25, 2021
donut cooked with Blender — @photosbysaurav on Instagram

In the original post — https://mrsauravsahu.medium.com/containers-and-kubernetes-on-macos-a-setup-for-2022-2bbba491f644 I discussed what my setup for containers and Kubernetes looks like, for 2022, when we’re back to coding after the holidays! 😉 There, I mainly discussed alternatives to Docker Desktop and introduced colima as my go-to solution for creating, managing and running containers and how these can be used with the integrated Kubernetes Setup colima provides.

After using colima for a couple of weeks now, I’d like to share with you some tweaks I’ve made to improve my experience.

Use Docker (sorry containerd)

colima supports both docker and containerd runtimes and I planned on ditching docker entirely in my previous post in the setup. After using containerd for a while, I want to backtrack a little bit.

In terms of creating and running containers, I had no issues whatsoever with containerd. I even published images to the Github Container Registry without any issues.

Issues with containerd

  • containerd compose: I experimented with containerd when I was running my personal website’s (mrsauravsahu.in) code locally. This site has a few services which I run with docker composelocally. Even though containerd is a great project, there are some kinks in containerd compose which couldn’t detect which services have changed since my last containerd compose up -d and I had to delete and recreate the stack everytime.
  • entrypoint scripts: My services in the docker-compose.yml had entrypoints customized per service, to run a specific command on top of shared docker files (one for node.js and another for dotnet). For example, one of my node services had this - entrypoint: 'sh -c "npm --prefix services/api install && npm --prefix services/api run start:dev"'. containerd was not happy with this 😂 currently, containerd doesn’t support multiple strings in entrypoint.

How to use Docker with Colima

What it means to use docker runtime is this, the VM colima sets up installs Docker Server, this can be connected to the macOS’s docker client. So, all you need to do is install docker (preferably through brew) with this command —

brew install docker

Now you can stop and delete the colima VM

colima stop
colima delete

And finally, create a new VM with

colima start --with-kubernetes -r docker --mount /Users/sauravsahu:w 
# colima uses docker runtime by default

Now creating and managing your images remains the same, with the docker command. Test out if everything works by running the hello-world container.

docker run hello-world

Note: I picked the latest version of colima with brew install --head colima to get all the latest functionality.

Writable Volumes

As pointed by a good friend (and a Docker, Kubernetes Guru 😏) in my post, colima doesn’t have write permission to the volumes. This is to prevent nefarious containers from corrupting your File System. If you want to allow write on your File System through colima, pass the w option on the --mount switch.

colima start --with-kubernetes -r docker --mount /Users/sauravsahu:w 
# Pass in your username instead of `sauravsahu`

Portainer: UI for your Containers

Sometimes, I like to use a UI to quickly check my containers and do any necessary cleanup. Portainer has a community edition which I really like to do all of this. Portainer can run as a regular container and you can use it to manage your containers.

Installation is fairly simple (more details here — https://docs.portainer.io/v/ce-2.9/start/install/server/docker/linux)

  • create a volume for portainer to store any data
docker volume create portainer_data
  • run the portainer container
docker run -d -p 9000:9000 --name portainer \\
--restart=always \\
-v /var/run/docker.sock:/var/run/docker.sock \\
-v portainer_data:/data \\

Portainer will now be available at http://localhost:9000/

UI for Kubernetes?

I personally just use kubectl and k9s for managing my cluster, but I heard from another friend 🤘😎 that rancher has a great user interface for managing Kubernetes clusters.

So those are the few improvements to my Docker setup. Do try these out and let me know if you’d still want to use Docker Desktop, and why?





Personal Opinions • Beyond Full Stack Engineer @ McKinsey & Company