Skip to main content

Lima: A Faster, Lighter Alternative to Docker Desktop on macOS

Preface

I have been using Lima instead of Docker Desktop for over a year. What started as an experiment to avoid Docker Desktop’s licensing fees turned into a permanent switch due to Lima’s superior performance and flexibility. This article shares my hands-on experience and practical setup guide for developers looking to make a similar transition.

What is Lima

Lima (Linux-on-Mac) is an open-source tool that launches Linux virtual machines on macOS with automatic file sharing and port forwarding. Think of it as a lightweight alternative to Docker Desktop, but with more flexibility and better performance.

Key Features

  • Built-in Container Support: Ships with containerd and nerdctl pre-configured
  • Native Performance: Uses virtiofs for efficient file sharing
  • Resource Efficient: Lower memory footprint compared to Docker Desktop
  • Multiple VM Support: Run different Linux distros simultaneously
  • Developer Friendly: Direct SSH access to VMs for debugging

Architectural Differences

Here’s how Lima differs from Docker Desktop at the architecture level:

Feature Docker Desktop Lima
Virtualization Hyperkit/Virtualization.Framework QEMU/Virtualization.Framework
Base System Custom LinuxKit Standard Linux distributions
Container Runtime Docker Engine containerd + nerdctl
File Sharing Custom implementation virtiofs/sshfs
Network Custom VPNKit User-space networking
Configurability Limited through GUI Fully configurable via YAML

Installation and Setup

Installing Lima and Docker tools

  1. Install Lima and Docker CLI via Homebrew:
brew install lima docker
  1. Create and start Lima VM with Virtualization.Framework:
limactl create --name=docker \
  --arch=aarch64 \
  --cpus=1 \
  --memory=2 \
  --disk=20 \
  --vm-type=vz \
  --mount-type=virtiofs \
  --mount=$HOME:w \
  template://docker

limactl start docker
  1. Configure Docker Context:
docker context create lima-docker --docker "host=unix://${HOME}/.lima/docker/sock/docker.sock"
docker context use lima-docker
docker run --rm hello-world
  1. Expected output:
docker run --rm hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
478afc919002: Pull complete
Digest: sha256:305243c734571da2d100c8c8b3c3167a098cab6049c9a5b066b6021a60fcb966
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (arm64v8)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

Reference