Yet Again, Docker macOS
After using the official Docker for Mac for a while, it became clear to me that the app is not yet stable and reliable enough to be used for professional use case in the background nor user-friendly, ready-to-go like a actual desktop mac app.
I toned down the setting and limiting the CPU to 2 cores with 4/3(?)GB RAM, and I also checked the box for using the new release virtualization framework in Experimental feature. However, the ram usage would still be going thr the limits and lagging, breakdown is also often seen. Eating roughly 4GB of RAM and I have seen errors where it said it used 30G but probably swap usage along with crashes…
As under the hook, the Docker for Mac still basically created a Linux VM, kind of like podman. The underlying performance issues might be the way the VM is regulated/managed. So, why not just create a VM and use docker cli or simply ssh to the linux instance?
There are a bit headaches and issues with Docker on macOS.
- IO has always been a really big issue, causing really slow build and even slow git for bigger project. I never tested on new build now.
- Volume mounting.
Although creating your own VM will also lead to a plate of problmes such as network device/video device/volume storage mounting. But those issues are also persistant on macOS app. After all its not linux.
Perfomance issues
The article caught my eyes as it compares docker build time on Intel/Apple Silicon Macs with different hyperviser.
The Table said it all, whatever it is, the Docker for Mac makes it hard for macOS to deliver the performance it is capable of. And that last line is the one I am interested.
device/volume mounting issue
For me, personally, theres a need to use the volume in Docker and that volume is not one M1’s SSD but on another network device mounted on macOS via SMB/CIFS.
It was slow on macOS itself and it will probably take a bigger blow with all that connection protocol added on top of that with introducing VM. So I am curious about how it went going forward.
Actual set up
A detailed post on setting up UTM VM with Docker on macOS
First, install UTM, a free and open source VM tool built only for macOS.
A minial debian build Debian 10.4 were used for installing Docker, in theory, more trimming can be done to reduce the overhead on that instance.
- Remeber to change root user(root/password) and default user(debian/debian):
|
|
- Update and install essential: SSH
Some problems with apt-get update: https://stackoverflow.com/questions/68802802/repository-http-security-debian-org-debian-security-buster-updates-inrelease
|
|
This confirms the SSH server is running and listening on port 22. If you need more help with that, PhoenixNap has a great tutorial on How to Enable SSH on Debian.
- Install Docker on Debian 10.4 VM
Follow: https://phoenixnap.com/kb/how-to-install-docker-on-debian-10
Change amd64 to arm64
|
|
Config macos Docker CLI to use VM’s Docker Enginer
|
|
We’ll get “permission denied” when trying to use the Docker CLI from macOS. This is because the debian user doesn’t have permissions to use Docker without using sudo. To fix this, on the Debian VM, we’ll run the following command to add the debian user to the docker user group:
|
|
Now the Docker CLI will connect to the Debian VM instead. We will confirm this by running docker system info | grep System from the macOS terminal to see that the operating system is Debian, not Darwin or macOS:
Working!
|
|
Problems with UTM
UI still freezes from time to time when I tried to resize/config the image. Thats annoying af.
Problems with porting:
It seems to I have to keep this ssh activa without CTRL+C
|
|
After I stopped, I need to remove sock and re-do the whole thing.
Solution: treat the VM as remote host and modify DOCKER_HOST
, ssh create a private key and adds it to VM.
|
|
CPU Benchmark (1000 difference with native sysbench)
Another post benchmark cpu using sysbench
With a threads=2, I got 105585 in ubuntu docker
|
|
|
|
WTF, why is VM takes such a dramatic hit, even with the right tool. I might ended up using the Sonarr/Radarr for macOS, 4.0.0 of Radarr already has osx-arm64 build, just waiting for Sonarr.
And yes, the QEMU used by UTM would still eat up about 2.3 GB RAM