Skip to content

Instantly share code, notes, and snippets.

@surenkov
Last active August 30, 2023 10:16
Show Gist options
  • Save surenkov/f1d47d0fd3aa75681ff39d5bf7736d01 to your computer and use it in GitHub Desktop.
Save surenkov/f1d47d0fd3aa75681ff39d5bf7736d01 to your computer and use it in GitHub Desktop.
Lima VM config with VirtioFS and macOS Virtualization Framework for Docker
vmType: "vz"
arch: "default"
images:
# Try to use release-yyyyMMdd image if available. Note that release-yyyyMMdd will be removed after several months.
- location: "https://cloud-images.ubuntu.com/releases/23.04/release-20230829/ubuntu-23.04-server-cloudimg-arm64.img"
arch: "aarch64"
digest: "sha256:5316a0dc05d83b6aad277b338ec67837792d0d695db1b736a59c8117114b8deb"
- location: "https://cloud-images.ubuntu.com/releases/23.04/release-20230829/ubuntu-23.04-server-cloudimg-amd64.img"
arch: "x86_64"
digest: "sha256:b79d654a4f4cee3691fbbda2ef4896b5bbadae40c60a0763c5ddfce6b21eff4f"
# Fallback to the latest release image.
# Hint: run `limactl prune` to invalidate the cache
- location: "https://cloud-images.ubuntu.com/releases/23.04/release/ubuntu-23.04-server-cloudimg-amd64.img"
arch: "x86_64"
- location: "https://cloud-images.ubuntu.com/releases/23.04/release/ubuntu-23.04-server-cloudimg-arm64.img"
arch: "aarch64"
cpus: 6
memory: "12GiB"
disk: "300GiB"
mounts:
- location: "~"
- location: "~/Projects"
writable: true
- location: "/tmp/lima"
writable: true
mountType: "virtiofs"
# ===================================================================== #
# ADVANCED CONFIGURATION
# ===================================================================== #
# containerd is managed by Docker, not by Lima, so the values are set to false here.
containerd:
system: false
user: false
provision:
- mode: system
script: |
#!/bin/bash
sed -i 's/host.lima.internal.*/host.lima.internal host.docker.internal/' /etc/hosts
- mode: system
script: |
#!/bin/bash
set -eux -o pipefail
command -v docker >/dev/null 2>&1 && exit 0
if [ ! -e /etc/systemd/system/docker.socket.d/override.conf ]; then
mkdir -p /etc/systemd/system/docker.socket.d
cat <<-EOF >/etc/systemd/system/docker.socket.d/override.conf
[Socket]
SocketUser=${LIMA_CIDATA_USER}
EOF
fi
DOCKER_CFG=/etc/docker
mkdir -p $DOCKER_CFG
cat <<-EOF >$DOCKER_CFG/daemon.json
{
"builder": {
"gc": {"enabled": true}
},
"experimental": true,
"features": {"buildkit": true},
"live-restore": true,
"host-gateway-ip": "$(dig host.lima.internal +short)"
}
EOF
export DEBIAN_FRONTEND=noninteractive
curl -fsSL https://get.docker.com | sh
# ===================================================================== #
# FURTHER ADVANCED CONFIGURATION
# ===================================================================== #
rosetta:
enabled: true
binfmt: true
networks:
# The "vzNAT" IP address is accessible from the host, but not from other guests.
- vzNAT: true
portForwards:
- guestSocket: "/var/run/docker.sock"
hostSocket: "{{.Dir}}/sock/docker.sock"
hostResolver:
enabled: true
ipv6: true
hosts:
host.docker.internal: host.lima.internal
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment