Colima for DDEV: An Docker Desktop Alternative

Colima for DDEV: An Docker Desktop Alternative

Mac users who currently rely on Docker Desktop for containerization may find it worthwhile to switch to Colima, a highly efficient and lightweight platform designed specifically for macOS.

In this article, we will guide you through the process of migrating from Docker Desktop to Colima.

What is DDEV?

DDEV is a local development environment tool that simplifies the process of building and managing web applications. You can use ddev with Colima to create a local development environment that can replicate the production environment of your application.

What is Colima?

Colima is a tool that simplifies running Docker containers on macOS by providing a QEMU VM with an HVF accelerator, port forwarding, and folder-sharing capabilities. It is built on top of Lima, which also has containerd and nerdctl, but requires Docker to be installed for full compatibility.

Colima features include Easy CLI, multiple profiles, support for multiple architectures (Intel, M1), Docker/container runtimes, and Kubernetes integration.

Resource usage:

Colima is engineered to be lightweight and utilize fewer resources than Docker Desktop. Its "micro-VM" architecture assigns each container to its individual, lightweight virtual machine, while Docker Desktop runs all containers within a single, more resource-intensive virtual machine.

This unique approach not only optimizes system resource utilization but can also improve overall performance.

User interface:

Docker Desktop comes with a built-in user interface that allows you to manage your containers, images, networks, and volumes, while Colima does not. Instead, Colima is designed to be used primarily from the command line.

Operating system support:

Docker Desktop is available for Windows, Mac, and Linux, while Colima is currently only available for Mac. This means that if you need to run containers on Windows or Linux, you will need to use Docker Desktop or another containerization tool.

Removing Docker Desktop

First thing, 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/
160G /Users/sonvir/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

Installing Colima

First, we need to install docker and docker-compose. We can install Kubernetes as well as per the need. Let's install everything from Homebrew

$ brew install docker docker-compose

This gives us the command line tools, but not a running Docker service. We can see that by running docker ps.

$ docker ps

Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

Next, to start the docker service we need to install Colima

$ brew install colima

Problems I faced while using Colima on Mac M1

$ colima start
limactl is running under rosetta

Solutions:

  1. Steps to uninstall rosetta 2

(Step-by-Step) How to Uninstall Rosetta 2 from an M1 Mac?

  1. Steps to install homebrew

Error: Cannot install in Homebrew on ARM processor in Intel default prefix (/usr/local)

  1. omz_urlencode:3: command not found: pygmentize --

https://gist.github.com/BretFisher/6f688dde0122399efdca5a9d26100437

Customizing Colima’s Virtual Machine

The default VM created by Colima has 2 CPUs, 2GiB memory, and 60GiB storage.

The VM can be customized either by passing additional flags to colima start. e.g. --cpu, --memory, --disk, --runtime. Or by editing the config file with colima start --edit.

To use 4 CPUs and 4GiB of memory with your existing machine, stop the machine and restart it, passing the --cpu and --memory options:

$ colima start --cpu 4 --memory 4

To create a VM with four CPUs, 4GB of memory, and 100GiB of disk space, start Colima with the following options:

$ colima start --cpu 4 --memory 4 --disk 100

Spin up a new Drupal 10 site via ddev config, ddev start, etc... (It is recommended to enable DDEV's mutagen functionality to maximize performance).

NOTE: Disk size cannot be changed after the VM is created. If you need more disk space, you have to create a new virtual machine.

Keep in mind that Colima does not auto-start when your machine turns on, so you will need to manually run colima start after each reboot.

Conclusion

Having thoroughly tested Colima, I can confidently say that it is an excellent replacement for Docker Desktop. Notably, it outperforms Docker Desktop when it comes to shared folder operations, making a compelling case for making the switch.

Additionally, I was able to seamlessly run DDEV and utilize all DDEV commands as before, which is a significant advantage as it did not require any modifications to my existing configs.