Skip to content

Instantly share code, notes, and snippets.

@crowjdh
Last active May 24, 2022 09:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save crowjdh/aa0af8af03ff752ef5caaeb88b2a3034 to your computer and use it in GitHub Desktop.
Save crowjdh/aa0af8af03ff752ef5caaeb88b2a3034 to your computer and use it in GitHub Desktop.

Install Lima

username@mac:workdir $ brew install lima

Prepare Docker-CLI & Docker Compose

Using Homebrew

username@mac:workdir $ brew install docker docker-compose

(Optional) Build from source

username@other-mac-with-docker:workdir $ git clone https://github.com/docker/cli.git && cd cli && docker buildx bake
# output: ./build/docker

username@other-mac-with-docker:workdir $ git clone https://github.com/docker/compose.git && cd compose && make
# output: ./bin/docker-compose

Setup

# Start Lima
username@mac:workdir $ limactl start --name=docker docker.yaml

# Create docker context for Lima
username@mac:workdir $ export LIMA_HOME="PATH_TO_LIMA_HOME"
username@mac:workdir $ docker context create lima --docker "host=unix://$(LIMA_HOME)/docker/sock/docker.sock"

# Optionally, you can do below to use lima as your default docker context.
username@mac:workdir $ export DOCKER_CONTEXT="lima"

Cheatsheet

# Obvious stuffs
username@mac:workdir $ limactl --help
username@mac:workdir $ limactl info
username@mac:workdir $ limactl ls

# Shell into base linux VM
username@mac:workdir $ limactl shell docker bash

# Start/Stop/Edit base linux VM
username@mac:workdir $ limactl start docker
username@mac:workdir $ limactl stop docker
username@mac:workdir $ limactl edit docker

(Optional) Update docker.yaml for Lima

# Tune VM host spec
cpus: 8
memory: 16GiB
disk: 60GiB

# Mount directories you want to expose
mounts:
- location: "~/Dev/docker"
  writable: true
- location: "~/Downloads"
  writable: true

References

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment