Speed-Up your Docker containers on macOS by enabling the new Virtualization Framework and VirtioFS
NextJS React app startup process goes from 20s to just 3
1 min read
If you are a software engineer that uses Docker containers on your macOS for development, you might have experienced how slow can they get sometimes, especially when they start up or with I/O intensive operations like installing dependencies.
Since macOS Big Sur, there is a new Virtualization Framework that software like Docker can use to access the computer resources more effectively. This, when combined with the new VirtioFS introduced in macOS Monterey 12.2 will make your containers fly like never before.
I especially notice the difference when starting my NextJS apps (it went from ~20 secs to ~3) or when installing dependencies (time is drastically better here).
With 3 NextJS apps running, I can see how much better my resources are used:
CPU (Idle containers: 3 - 5 %)
Allocated Memory (8.02 GB of the maximum configured for Docker, 8.00 GB)
Before this, Docker was using
qemu and it was eating a lot of memory (more than the limit I configured).
All you need to do, if you have macOS 12.2 or greater, is to enable these experimental features in your Docker for Mac settings, and restart it: