Drop-in replacement for Docker Desktop under macOS
This is going to be a short but sweet one to everyone who uses Docker Desktop and is looking to save a buck.
Since February 1st 2022, Docker Desktop requires a paid subscription from anyone who is developing commercial software using Docker Desktop and whose annual revenue exceeds $10 million OR who has over 250 employees. While I appreciate everything that Docker has allowed the software industry to achieve in the last 10 years and I understand why they switched to a new business model with Docker Desktop, this means significant costs for all the companies that rely on it.
“Its an open-source alternative to Docker Desktop that will be a drop-in replacement.”
In this article I will go over a free alternative to Docker Desktop that will be a drop-in replacement, meaning that besides setting up the software, you shouldn’t need to change ANYTHING else when it comes to your images, containers or how you interact with docker or docker-compose.
The tool that we are going to use is Colima. It’s using Lima, which allows running Linux virtual machines on macOS. The name literally derives from ‘LInux MAchines’ and — you guessed it — Colima is just ‘COntainers on LInux MAchines’.
The first thing you need to do is remove the Docker Desktop. Unfortunately, this is more complicated than it sounds at first, but luckily other people have already created a checklist to follow. Please follow these steps carefully!
You need to have Homebrew installed because we are going to install the docker CLI, docker-compose and docker-credential-helper.
brew install docker docker-compose docker-credential-helper
mkdir -p ~/.docker/cli-plugins
ln -sfn $(brew --prefix)/opt/docker-compose/bin/docker-compose ~/.docker/cli-plugins/docker-compose
“The cool thing about Colima is that it can actually outperform Docker Desktop.”
Now we’ll install Colima.
brew install colima
The only thing left to do now is to start up a Colima runtime. The cool thing about Colima is that it can actually outperform Docker Desktop. The reason? Docker Desktop uses a QEMU virtual machine and so does Colima by default. Thanks to the release of macOS 13 there is now a new and better performing Virtualization.Framework option, which can be used together with Rosetta 2. Also, a big bottleneck for docker on macOS is storage. Virtiofs type of storage system seems to be offering fast and stable performance.
So, let’s see how it all works. We would start our Colima machine with the following command:
#30 gigabytes of RAM
#8 CPU cores
#Virtualization.Framework
#Virtiofs storage
#Enable network IP to be accessed from outside (Xdebug)
#Rosetta2
colima start -m 30 -c 8 --vm-type=vz --mount-type=virtiofs --network-address --vz-rosetta
Assign as much CPU/RAM as you have (or as little) — you probably don’t want to bottleneck your containers — but don’t exceed actual physical amounts on your computer. On Apple’s M1/M2 CPUs only the performance cores can be used — efficiency ones aren’t supported.
Run docker info
, it should tell you that Docker really is via Colima.
$ docker info
Client:
Context: colima
Debug Mode: false
Plugins:
compose: Docker Compose (Docker Inc., 2.15.1)
So, with little luck, you should now be able to use docker just like before, only now without Docker Desktop.
Troubleshooting
Getting segmentation errors in containers with Apache + PHP
If you are running Rosetta 2, it seems that PHP’s OPcache cannot be used together with Apache. One solution is to disable OPcache extension:
cd /usr/local/etc/php/conf.d
mv docker-php-ext-opcache.ini docker-php-ext-opcache.ini.disabled
Error getting credentials — err: docker-credential-desktop resolves to executable in current directory (./docker-credential-desktop)
Check the ~/.docker/config.json file and remove the following line:
“credsStore”: “desktop”,
Docker is unavailable after the system reboot
Colima doesn’t start automatically. Run colima start
to boot up the machine with the previously used configuration. All containers will also auto-start within it.
To see the full configuration options, run start with -e flag:
colima start -e
NodeJS file watcher or hot reload doesn’t work
Tracking file changes in container that are made from the host has a bug, which makes using standard file watchers not possible. There is a ticket open about in Colima’s repository, so hopefully it will get fixed soon. Meanwhile an option is to use old-school polling methodology.
watchOptions: {
poll: 1000, // Check for changes every second
},
If you like Docker and you enjoy getting the best out of the tools that a developer needs daily, make sure to check out our open positions at https://www.scoro.com/careers/