How VMs work on Apple Silicon
In this lesson I create a Linux virtual machine on an Apple Silicon Mac with Colima and point docker at it. At the end you have a virtual machine called lab that runs your containers. Before you start you need homebrew and three of its packages colima lima and docker the docker command line. The install command is brew install colima lima docker they are already installed here so I list the their versions. Colima 0.1 0.3, Lima 2.3.0 and docker 29.9.3. These are the versions I use in the whole course. Containers need Linux kernel and macOS is not Linux, so on a mac containers run inside a Linux virtual machine or VM. macOS includes Apple's virtualization framework which runs Linux VMs directly on the processor cores of your Mac. These tools call it VZ for short. The older option is QEMU, an emulator that also runs on Intel Macs and can imitate other processors. It is slower on Apple silicon, VZ is the default and the better choice. Lima, short for Linux machines, creates and runs these VMs and shares files and network ports with the Mac. Colima, short for Containers on Lima, builds on Lima. It gives you a VM with a container runtime already set up. Colima keeps each VM in a profile. Without a name you get a profile called default. I name mine lab and I choose its size, the Vise type, two CPUs which are virtual processor cores, 2 GB of memory and a disk of 20 GB for container images. The first start downloads an Ubuntu disk image, I downloaded it before recording, so here it takes a few seconds. The log shows Lima at work, it boots the VM, waits for SSH, the secure shell it uses to reach the VM, forwards the docker socket to the Mac, and installs emulators for other processors. Done! Colima list shows every profile with its status and size. Colima also created a docker context and named a connection that tells the docker command where its daemon runs and made it the current one. The star marks it. So from now on, every docker command talks to the docker daemon inside the LabBM. Docker info confirms it, the daemon runs on Ubuntu, on the ARM64 architecture with the two CPUs I gave the VM. Now a first container, Alpine, is a small Linux image and you name M prints the processor architecture. ARC64 is the Linux name for 64-bit ARM, the processor design of Apple Silicon. The container runs on the cores of the Mac without any emulation. You can also reach the VM itself. Colima SSH opens a shell in it and with two dashes it runs one command and comes back. The P flag names the profile. A Linux kernel on ARM64. That is the whole stack. The Docker command on the Mac, a Docker daemon in a Linux VM and Apple's virtualization framework under it. the VM keeps running in the background until you stop it.