Skip to main content

Command Palette

Search for a command to run...

Replacing Docker Desktop with Lima on Mac OS

Published
1 min read

As Docker Desktop is no longer free to use, I spent my workday trying alternatives and setup Lima on Big Sur. Here are my notes that I will probably end up googling myself at some point :D

brew install docker
brew install docker-compose
brew install lima
limactl start

*If limactl isn't found, start a new terminal.

Press enter to start with the default configuration.

Download Lima's docker.yaml

limactl start ./docker.yaml
docker context create lima --docker "host=unix://{{.Dir}}/sock/docker.sock"
docker context use lima

You should now be able to run docker or docker-compose!

By default Lima mounts volumes as readonly.

I wasn't done yet, as I needed writable volumes in my projects that were all under ~/Code. We can modify the config that lima is using.

First stop the lima vm.

limactl stop docker

Edit ~/.lima/docker/lima.yaml, I threw in my Code folder as a writable mount:

mounts:
- location: "~"
- location: "~/Code"
  writable: true
- location: "/tmp/lima"
  writable: true

Start the lima vm.

limactl start docker

Notes:

*If you see the error error getting credentials - err: exec: "docker-credential-desktop": executable file not found in $PATH In ~/.docker/config.json change credsStore to credStore

*You shouldn't need to set this, but if you need the env var DOCKER_HOST

export DOCKER_HOST=$(limactl list docker --format 'unix://{{.Dir}}/sock/docker.sock')
C

To use the new docker compose command you'll also need to symlink it as a docker plugin manually:

    mkdir -p ~/.docker/cli-plugins
    ln -sfn $(brew --prefix)/opt/docker-compose/bin/docker-compose ~/.docker/cli-plugins/docker-compose
C

And if you run into docker-credential-desktop errors when trying to use docker{-, }compose try renaming credsStore to credStore in ~/.docker/config.json

D

you can also ditch docker all together with colima, a lima install that comes bundled with containerd as a container runtime, or you can just swap in podman for docker.