Skip to content

Instantly share code, notes, and snippets.

@pythoninthegrass
Last active May 27, 2024 19:15
Show Gist options
  • Save pythoninthegrass/7a1ca981a82c3f91d7fbdd861b2584a2 to your computer and use it in GitHub Desktop.
Save pythoninthegrass/7a1ca981a82c3f91d7fbdd861b2584a2 to your computer and use it in GitHub Desktop.
Lima custom YAML configs
# https://github.com/lima-vm/lima/blob/master/examples/docker-rootful.yaml
---
images:
# Hint: run `limactl prune` to invalidate the "current" cache
- location: "https://download.fedoraproject.org/pub/fedora/linux/releases/40/Cloud/x86_64/images/Fedora-Cloud-Base-Generic.x86_64-40-1.14.qcow2"
arch: "x86_64"
digest: "sha256:ac58f3c35b73272d5986fa6d3bc44fd246b45df4c334e99a07b3bbd00684adee"
- location: "https://download.fedoraproject.org/pub/fedora/linux/releases/40/Cloud/aarch64/images/Fedora-Cloud-Base-Generic.aarch64-40-1.14.qcow2"
arch: "aarch64"
digest: "sha256:ebdce26d861a9d15072affe1919ed753ec7015bd97b3a7d0d0df6a10834f7459"
mounts:
- location: "~"
- location: "/tmp/lima"
writable: true
cpus: 2
memory: 2GiB
mountType: virtiofs
# ! macos-only
# networks:
# - lima: shared
# interface: en0
portForwards:
- guestPortRange:
- 1
- 65535
hostIP: 0.0.0.0
- guestSocket: "/var/run/docker.sock"
hostSocket: "{{.Dir}}/sock/docker.sock"
hostResolver:
hosts:
host.docker.internal: host.lima.internal
vmType: qemu # qemu / vz (macos-only)
containerd:
system: false
user: false
provision:
- mode: system
script: |
#!/bin/sh
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
curl -fsSL https://get.docker.com | sh
- mode: user
script: |
dockerd-rootless-setuptool.sh install
sudo loginctl enable-linger {{.User}}
probes:
- script: |
#!/bin/bash
set -eux -o pipefail
if ! timeout 30s bash -c "until command -v docker >/dev/null 2>&1; do sleep 3; done"; then
echo >&2 "docker is not installed yet"
exit 1
fi
- script: |
#!/bin/bash
set -eux -o pipefail
if ! timeout 30s bash -c "until systemctl --user is-active docker.service >/dev/null 2>&1; do sleep 3; done"; then
echo >&2 "docker.service is not running yet"
exit 1
fi
hint: |
See "/var/log/cloud-init-output.log". in the guest
message: |
To run `docker` on the host (assumes docker-cli is installed), run the following commands:
------
docker context create lima-{{.Name}} --docker "host=unix://{{.Dir}}/sock/docker.sock"
docker context use lima-{{.Name}}
docker run hello-world
------
# https://github.com/lima-vm/lima/blob/master/examples/docker-rootful.yaml
---
images:
# Hint: run `limactl prune` to invalidate the "current" cache
- location: "https://cloud-images.ubuntu.com/releases/focal/release-20240513/ubuntu-20.04-server-cloudimg-amd64.img"
arch: "x86_64"
digest: "sha256:aed3ea05262772dd2b525887a023af2eda181023ad70312537bf1a5397d6ddaa"
- location: "https://cloud-images.ubuntu.com/releases/focal/release-20240513/ubuntu-20.04-server-cloudimg-arm64.img"
arch: "aarch64"
digest: "sha256:cab7a22846ecea693c987da0e78d91c661593da66c924829591c3ec159fe5ab3"
# Fallback to the latest release image.
- location: "https://cloud-images.ubuntu.com/releases/focal/release/ubuntu-20.04-server-cloudimg-amd64.img"
arch: "x86_64"
- location: "https://cloud-images.ubuntu.com/releases/focal/release/ubuntu-20.04-server-cloudimg-arm64.img"
arch: "aarch64"
mounts:
- location: "~"
- location: "/tmp/lima"
writable: true
cpus: 2
memory: 2GiB
mountType: virtiofs
# ! macos-only
# networks:
# - lima: shared
# interface: en0
portForwards:
- guestPortRange:
- 1
- 65535
hostIP: 0.0.0.0
- guestSocket: "/var/run/docker.sock"
hostSocket: "{{.Dir}}/sock/docker.sock"
hostResolver:
hosts:
host.docker.internal: host.lima.internal
vmType: qemu # qemu / vz (macos-only)
containerd:
system: false
user: false
provision:
- mode: system
script: |
#!/bin/sh
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
# Alternatively we could just add the user to the "docker" group, but that requires restarting the user session
cat <<-EOF >/etc/systemd/system/docker.socket.d/override.conf
[Socket]
SocketUser={{.User}}
EOF
fi
export DEBIAN_FRONTEND=noninteractive
curl -fsSL https://get.docker.com | sh
probes:
- script: |
#!/bin/bash
set -eux -o pipefail
if ! timeout 30s bash -c "until command -v docker >/dev/null 2>&1; do sleep 3; done"; then
echo >&2 "docker is not installed yet"
exit 1
fi
if ! timeout 30s bash -c "until pgrep dockerd; do sleep 3; done"; then
echo >&2 "dockerd is not running"
exit 1
fi
hint: |
See "/var/log/cloud-init-output.log". in the guest
message: |
To run `docker` on the host (assumes docker-cli is installed), run the following commands:
------
docker context create lima-{{.Name}} --docker "host=unix://{{.Dir}}/sock/docker.sock"
docker context use lima-{{.Name}}
docker run hello-world
------
# https://github.com/lima-vm/lima/blob/master/examples/docker-rootful.yaml
---
images:
# Hint: run `limactl prune` to invalidate the "current" cache
- location: "https://cloud-images.ubuntu.com/releases/24.04/release-20240423/ubuntu-24.04-server-cloudimg-amd64.img"
arch: "x86_64"
digest: "sha256:32a9d30d18803da72f5936cf2b7b9efcb4d0bb63c67933f17e3bdfd1751de3f3"
- location: "https://cloud-images.ubuntu.com/releases/24.04/release-20240423/ubuntu-24.04-server-cloudimg-arm64.img"
arch: "aarch64"
digest: "sha256:c841bac00925d3e6892d979798103a867931f255f28fefd9d5e07e3e22d0ef22"
# Fallback to the latest release image.
- location: "https://cloud-images.ubuntu.com/releases/24.04/release/ubuntu-24.04-server-cloudimg-amd64.img"
arch: "x86_64"
- location: "https://cloud-images.ubuntu.com/releases/24.04/release/ubuntu-24.04-server-cloudimg-arm64.img"
arch: "aarch64"
mounts:
- location: "~"
- location: "/tmp/lima"
writable: true
cpus: 2
memory: 2GiB
mountType: virtiofs
# ! macos-only
# networks:
# - lima: shared
# interface: en0
portForwards:
- guestPortRange:
- 1
- 65535
hostIP: 0.0.0.0
- guestSocket: "/var/run/docker.sock"
hostSocket: "{{.Dir}}/sock/docker.sock"
hostResolver:
hosts:
host.docker.internal: host.lima.internal
vmType: qemu # qemu / vz (macos-only)
containerd:
system: false
user: false
provision:
- mode: system
script: |
#!/bin/sh
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
# Alternatively we could just add the user to the "docker" group, but that requires restarting the user session
cat <<-EOF >/etc/systemd/system/docker.socket.d/override.conf
[Socket]
SocketUser={{.User}}
EOF
fi
export DEBIAN_FRONTEND=noninteractive
curl -fsSL https://get.docker.com | sh
probes:
- script: |
#!/bin/bash
set -eux -o pipefail
if ! timeout 30s bash -c "until command -v docker >/dev/null 2>&1; do sleep 3; done"; then
echo >&2 "docker is not installed yet"
exit 1
fi
if ! timeout 30s bash -c "until pgrep dockerd; do sleep 3; done"; then
echo >&2 "dockerd is not running"
exit 1
fi
hint: |
See "/var/log/cloud-init-output.log". in the guest
message: |
To run `docker` on the host (assumes docker-cli is installed), run the following commands:
------
docker context create lima-{{.Name}} --docker "host=unix://{{.Dir}}/sock/docker.sock"
docker context use lima-{{.Name}}
docker run hello-world
------
@pythoninthegrass
Copy link
Author

git clone git@gist.github.com:7a1ca981a82c3f91d7fbdd861b2584a2.git lima_configs && cd $_
limactl start ./ubuntu-2404.yml --tty=false

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