How I ended up using Colima for Docker on Apple Silicon
Tags: docker, macos, osx
Published: 2024-05-03 21:59:00

This year I got the chance to work with an Apple Silicon-based MacBook Pro, and what neat machines they are!
Compared to my Dell XPS 9500, the difference is night and day. These ARM based devices are fast and cool (both literally and figuratively), whereas the XPS can often sound like a helicopter taking off.
(It doesn't help that I got a device equipped with a 4K screen, but that's another story).

Because of the [pricing change](https://www.docker.com/blog/updating-product-subscriptions) that happened back in August 2021, I couldn't use Docker Desktop that I suppose everyone got accustomed to throughout the years, so just like I did on Windows back then, I started looking for a replacement.

## Podman

A lot of well-known Docker alternatives emerged at this point, the most commonly recommended of which must be [Podman](https://github.com/containers/podman) (along with Podman Desktop).
This is what I use on my Windows machines, and this was the first solution that I tried on the Macbook as well.

The setup was pretty straightforward, as it usually is with Homebrew:

```bash
brew install podman-desktop
```

Everything was working flawlessly, especially with the `podman-compose` extension installed, which allowed me to run compose files.

The first problems arose, when I needed to run a compose file, that contained x64 images.
Even though, in theory, it should've been possible, it didn't matter how much time I spent on following various tutorials, reinitializing podman-machines, messing with QEMU flags, I just couldn't get the thing working.

## Colima

While looking into the issue with Podman, I came across [colima](https://github.com/abiosoft/colima).
Apart from being able to run AMD64 images out of the box, there were additional benefits to it, one of which was, unlike podman, colima could use Rosetta 2 for x64 emulation (which is significantly more performant).

### Setup

The installation was pretty simple.
First, you need to make sure that you have Rosetta installed:

```bash
softwareupdate --install-rosetta
```

Then just install colima, Docker and compose:

```bash
brew install colima
brew install docker docker-compose
```

Now you can start colima, but let's edit the machine defaults first. You can do both with the following:

```bash
colima start --edit
```

Now edit the configuration file that's just opened in your default editor.
Make the following config changes to use :

```bash
vmType: vz
rosetta: true
mountType: virtiofs
# optionally adjust whatever else you want
# I suggest increasing the available cpu cores and RAM by editing `cpu` and `memory`
```

There! Now you can run all the Docker images you want by using the usual Docker CLI, since colima set itself up as a Docker context.

### Drawbacks

Unlike docker-desktop or podman-desktop, you need to manually start colima every time you log off. You can work around this by using [brew-services](https://github.com/Homebrew/homebrew-services):

```bash
brew services start colima
```

Another disadvantage is that you don't get a GUI. Personally, this isn't a big deal for me, I opted for the `-desktop` versions just because of the ease of installation _(something something Windows user and GUIs)_ but I only ever used the CLIs anyway.

---

## TL;DR

- If you are an individual dev, you can use the good old Docker-Desktop
- If you are a business user, and you want a GUI, use [Podman-Desktop](https://github.com/containers/podman-desktop), unless you want to run x64 images
- Otherwise, set up [Colima](https://github.com/abiosoft/colima)

---

_Originally published at [https://marczin.dev](https://marczin.dev/blog/macos-docker-setup/) on December 10, 2023._