Docker Desktop vs Colima on Mac M1 for working with VSCode containers

Docker Desktop vs Colima on Mac M1 for working with VSCode containers


Introduction

I am assuming that you have a basic understanding of docker and devcontainers and have used them before. As this post revolves around Mac M1, I’d suggest not using this analysis for comparing other systems in general.

VSCode devcontainers are the new way of starting a project development environment. They are a great way to get started with a project without having to install all the dependencies on your local machine. This reduces the setup time and allows you to get started with the project right away.

Devcontainers are powered by Docker and VSCode. VSCode provides the UI and Docker provides the containerization. This means that you need to have Docker installed on your machine to use devcontainers.

While docker is the main engine, Docker Desktop and Colima are the two main options for creating a docker environment on Mac.

Colima is an open-source alternative to Docker Desktop. While both software are free to use, Docker Desktop requires companies to pay for a license if they have more than 250 employees. And also, Docker Desktop can be enhanced with lots of extensions which Colima can’t.

I am using docker for mainly 2 things, creating production-level containers and using devcontainers for development. So a lot of Docker Desktop extensions are not useful for me but the performance is.

I analyzed the read/write performance of Docker Desktop and Colima for working with devcontainers and here are the results. I also compared the build time for my blog on both the software.

System Information

I am using a Macbook Air M1 with 16 GB RAM. I have allocated 8 GB RAM and 4 CPUs to Docker Desktop and Colima each. I also kept the disk storage to 60 GB for both the software which would be enough for our testing.

Docker Desktop

I’m using Docker Desktop v24.2 which comes with a 60% improvement in read/write performance (as they say). It’s using Apple’s VZ for virtualization and the net says it is far more optimized than Qemu. I have no extensions installed on Docker Desktop. And no other container was running at the time of analysis.

Colima

The latest version of Colima is v0.5.5 at the time of writing this article. It was released on May 2023. For the comparison, I’m using the HEAD of the Colima repository to capture any latest improvements.

I tested Colima with both Qemu and VZ virtualization.

Using the HEAD can be unstable compared to the release branches.

Analysis Procedure

I created a simple Java app for writing files of size 1 MB to 1 GB and calculated the time it takes to write each of the files. File sizes are 1 MB, 10 MB, 64 MB, 128 MB, 256 MB, 512 MB, and 1024 MB.

I created an arbitrary 1 GB file and accessed the random positions 1,000 to 1,000,000 times and calculated the average.

I also calculated the time it takes to print lines on the console using sout. I printed 10,000, 100,000, and 1,000,000 lines of 1 to 1000 characters each and calculated the average time.

You can find the Java app here.

My blog is made on AstroJs which generates a static site on build. The build process involves compressing the images, minifying the CSS and JS, MDX to MD conversion, HTML conversion and so on. This uses a lot of read/write operations hence I think it would be a good test of the performance. So I calculated the build time and the first render time of the blog on both systems to get a real feel of the performance.

Changing between Docker Desktop and Colima

I made sure to shut down Colima before starting Docker Desktop and vice versa. Docker desktop can be switched on/off from the UI.

Commands Used

Colima stop and delete settings

colima stop
colima delete

Start Colima

To start Qemu mode

colima start --cpu 4 --memory 8 --arch aarch64 --vm-type qemu

To start VZ mode

colima start --cpu 4 --memory 8 --arch aarch64 --vm-type=vz --vz-rosetta

Results

Write Performance

Docker Desktop

File sizeDuration (Worst)Duration (Best)
1 MB311 ms227 ms
10 MB1998 ms (2s)1943 ms (2 s)
64 MB14433 ms (14 s)12016 ms (12 s)
128 MB24745 ms (24 s)23455 ms (23 s)
256 MB58937 ms (1 min)52252 ms (52 s)
512 MB114213 ms (1.9 min)110060 ms (1.8 min)
1024 MB262955 ms (4.38)194817 ms (3.2 min)

Colima (Qemu)

File SizeDuration (Worst)Duration (Best)
1 MB573 ms286 ms
10 MB3077 ms (3s)2345 ms
64 MB19087 ms (19 s)14116 ms
128 MB38191 ms (38 s)26096 ms
256 MB81071 ms (1.35 min)67062 ms
512 MB151242 ms (2.52 min)159663 ms
1024 MB293370 ms (4.89 min)301629 ms

Colima (VZ + Rosetta 2)

File sizeDuration (worst)Duration (best)
1 MB291 ms236 ms
10 MB2113 ms (2s)2199 ms
64 MB12453 ms (12 s)12262 ms
128 MB25315 ms (25 s)24603 ms
256 MB49837 ms (49 min)50475 ms
512 MB101883 ms (1.69 min)100692 ms
1024 MB198126 ms (3.30 min)200163 ms

Read Performance

Shockingly, the read performance of Docker Desktop is very bad compared to Colima with a peak of 13 reads/ms. Colima with Qemu has a peak of 729 reads/ms and Colima with VZ has a peak of 705 reads/ms which is almost comparable.

Surprisingly, the read performance of Qemu is better than VZ.

Docker Desktop

number of random readsDuration (Total)Average Speed
1,000,00080593 - 81941 ms12 reads/ms
500,00038238 - 39058 ms12 - 13 reads/ms
200,00015299 - 15368 ms12 - 13 reads/ms
100,0007755 - 7895 ms12 reads/ms
10,000726 - 876 ms11 - 12 reads/ms
1,00081 - 107 ms9 - 12 reads/ms

I ran this 5 times and even restarted the docker engine multiple times but the results were the same. If anyone knows why this is happening, please let me know.

Colima (Qemu)

number of random readsDuration (Total)Average Speed
1,000,0001415 - 1419 ms704 - 707 reads/ms
500,000686 - 695 ms696 - 719 reads/ms
200,000276 - 278 ms719 - 728 reads/ms
100,000137 - 141 ms709 - 724 reads/ms
10,00015 - 17 ms666 - 729 reads/ms
1,0002 - 3 ms333 - 500 reads/ms

Colima (VZ + Rosetta 2)

number of random readsDuration (Total)Average Speed
1,000,0001493 - 1507 ms663 - 669 reads/ms
500,000709 - 721 ms693 - 705 reads/ms
200,000284 - 286 ms699 - 704 reads/ms
100,000143 ms699 reads/ms
10,00015 - 16 ms625 - 666 reads/ms
1,0001 -2 ms500 - 1000 reads/ms

Docker Desktop has the best print performance of all the three with a peak of 4074 chars/ms. Colima with VZ comes second with a peak of 2984 chars/ms.

Docker Desktop

number of lines to printnumber of chars printedtotal timeAvg (per line)Avg (per character)
10,0004,997,0481346 ms7 lines/ms3712 chars/ms
100,00049.999,88112272 ms8 lines/ms4074 chars/ms
1,000,000500,324,217122849 ms8 lines/ms4072 chars/ms

Colima (Qemu)

number of lines to printnumber of chars printedtotal timeAvg (per line)Avg (per character)
10,0005,013,9962019 ms4 lines/ms2483 chars/ms
100,00050,028,33919253 ms5 lines/ms2598 chars/ms
1,000,000500,593,068180024 ms5 lines/ms2780 chars/ms

Colima (VZ + Rosetta 2)

number of lines to printnumber of chars printedtotal timeAvg (per line)Avg (per character)
10,0005,030,5771752 ms5 lines/ms2871 chars/ms
100,00050,010,99716755 ms5 lines/ms2984 chars/ms
1,000,000499,828,875169597 ms5 lines/ms2947 chars/ms

Blog Performance

SystemBuild timeInitial rendering time
Host673 - 711 s42.69 ms
Colima (Qemu)817 - 836 s6.7 s
Colima (VZ + Rosseta)671 - 924 s4.8 s
Docker Desktop824 - 828 s5.6 s

Compared to the host, the build time is almost the same for all the systems but Colima with VZ is the best among them with the fastest build comparable to the host system. None of them came close to the host system in terms of rendering time (as expected).

Summary

Docker Desktop can be a better option for apps that require a lot of printing but fewer Read/Write operations. When it comes to extensive Read/Write operations, Colima with VZ + Rosseta 2 would be my choice because it gives you better write and print performance than Qemu. For my blog, I will be using Colima with VZ + Rosseta 2 because it gives me the best build time and read/write performance.