| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | minimumLimaVersion: 2.0.0 |
| 10 | |
| 11 | base: |
| 12 | - template:_images/ubuntu-lts |
| 13 | - template:_default/mounts |
| 14 | |
| 15 | |
| 16 | containerd: |
| 17 | system: false |
| 18 | user: false |
| 19 | provision: |
| 20 | - mode: system |
| 21 | |
| 22 | |
| 23 | |
| 24 | |
| 25 | script: | |
| 26 | #!/bin/sh |
| 27 | sed -i 's/host.lima.internal.*/host.lima.internal host.docker.internal/' /etc/hosts |
| 28 | - mode: system |
| 29 | script: | |
| 30 | #!/bin/bash |
| 31 | set -eux -o pipefail |
| 32 | command -v docker >/dev/null 2>&1 && exit 0 |
| 33 | export DEBIAN_FRONTEND=noninteractive |
| 34 | curl -fsSL https://get.docker.com | sh |
| 35 | - mode: yq |
| 36 | path: /etc/systemd/system/docker.socket.d/override.conf |
| 37 | format: ini |
| 38 | expression: .Socket.SocketUser="{{.User}}" |
| 39 | - mode: yq |
| 40 | path: "/etc/docker/daemon.json" |
| 41 | expression: | |
| 42 | .features.cdi = true | |
| 43 | .features.containerd-snapshotter = {{.Param.containerdSnapshotter}} |
| 44 | probes: |
| 45 | - script: | |
| 46 | #!/bin/bash |
| 47 | set -eux -o pipefail |
| 48 | if ! timeout 30s bash -c "until command -v docker >/dev/null 2>&1; do sleep 3; done"; then |
| 49 | echo >&2 "docker is not installed yet" |
| 50 | exit 1 |
| 51 | fi |
| 52 | if ! timeout 30s bash -c "until pgrep dockerd; do sleep 3; done"; then |
| 53 | echo >&2 "dockerd is not running" |
| 54 | exit 1 |
| 55 | fi |
| 56 | hint: See "/var/log/cloud-init-output.log" in the guest |
| 57 | hostResolver: |
| 58 | |
| 59 | |
| 60 | hosts: |
| 61 | host.docker.internal: host.lima.internal |
| 62 | portForwards: |
| 63 | - guestSocket: "/var/run/docker.sock" |
| 64 | hostSocket: "{{.Dir}}/sock/docker.sock" |
| 65 | message: | |
| 66 | To run `docker` on the host (assumes docker-cli is installed), run the following commands: |
| 67 | ------ |
| 68 | docker context create lima-{{.Name}} --docker "host=unix://{{.Dir}}/sock/docker.sock" |
| 69 | docker context use lima-{{.Name}} |
| 70 | docker run hello-world |
| 71 | ------ |
| 72 | {{- if .Instance.Config.VMOpts.vz.rosetta.enabled}} |
| 73 | Rosetta is enabled in this VM, so you can run x86_64 containers on Apple Silicon. |
| 74 | You can use Rosetta AOT Caching with the CDI spec: |
| 75 | - To run a container, add `--device=lima-vm.io/rosetta=cached` to your `docker run` command: |
| 76 | ------ |
| 77 | docker run --platform=linux/amd64 --device=lima-vm.io/rosetta=cached ... |
| 78 | ------ |
| 79 | - To build an image, add `# syntax=docker/dockerfile:1-labs` at the top of your Dockerfile, |
| 80 | and use `--device=lima-vm.io/rosetta=cached` in the `RUN` command: |
| 81 | ------ |
| 82 | # syntax=docker/dockerfile:1-labs |
| 83 | FROM ... |
| 84 | ... |
| 85 | RUN --device=lima-vm.io/rosetta=cached <your amd64 command> |
| 86 | ------ |
| 87 | See: https://lima-vm.io/docs/config/multi-arch/#rosetta-aot-caching |
| 88 | {{- end}} |
| 89 | param: |
| 90 | containerdSnapshotter: true |