lima-docker-lean

lima-docker-lean: Docker on macOS with near-zero idle cost

English · Русский

License: MIT Lima 2.2 Apple Silicon Virtualization.framework

A measured, minimal Docker host for Apple Silicon Macs, built on Lima and Apple’s Virtualization.framework. When idle it writes nothing to disk and uses about 1% of one core. Unlike a stock Lima VM, it lets macOS take back about half of the RAM the VM holds after a load. It is a real Docker Engine with docker.sock, so testcontainers, docker compose, buildx and werf work unchanged.

This is not another wrapper. It is one Lima template plus the analysis behind every line of it, with the raw benchmark output included.

Results

Apple M5, 16 GB, macOS 26.6, Lima 2.2.0, 4 vCPU / 6 GiB guest. Single runs; see limitations.

  Stock Alpine on Lima This template
Idle host CPU (empty VM) 1.31% of a core 1.00–1.12%
Idle disk writes ~25 KB/min (why) 0 B
limactl restart → ready ~26 s ~14 s
Host RAM really held after a Postgres + FoundationDB load ~4.2 GB ~2.1 GB (how)
pgbench (8 clients) / FoundationDB writes ~15k tps / ~246k keys/s same

Quick start

brew install lima docker            # Lima >= 2.2 and the docker CLI (+ compose/buildx plugins)
git clone https://github.com/heaprip/lima-docker-lean && cd lima-docker-lean

limactl start --name=dev ./templates/minimal-docker.yaml
limactl restart dev                 # once, to boot with init_on_free=1

docker context create lima-dev --docker "host=unix://$HOME/.lima/dev/sock/docker.sock"
docker context use lima-dev
docker run --rm -p 8080:80 nginx:alpine   # published ports appear on localhost

For testcontainers, point DOCKER_HOST at the same socket (or use the context). When you are not working, limactl stop dev brings the cost to zero.

What the template does

Each of these is explained and measured in the analysis:

Findings in short

Repository layout

templates/   minimal-docker.yaml (recommended), minimal-docker-iso.yaml (immutable alternative)
docs/en/     analysis.md: full write-up with methodology and limitations
docs/ru/     analysis.md: the same in Russian
bench/       idle.sh, disk-writes.sh, wakeups.sh, load.sh, memtest.sh, fdbbench.py
results/     raw output of every run quoted in the docs

Reproduce

./bench/idle.sh dev 120 60      # empty idle: host CPU, guest disk I/O, memory
./bench/load.sh dev             # Postgres + FoundationDB: idle with containers, load, idle after
./bench/memtest.sh dev          # real host RAM cost after load (stops the VM!)

License

MIT. Measurements and write-up by @heaprip, assisted by Claude.