Skip to content

Commit 5267044

Browse files
committed
docker.yaml: add .param.ContainerdImageStore
By passing the `--set .param.ContainerdImageStore=true` option to `limactl {create,start,edit}`, the `.features."containerd-snapshotter"` option will be enabled in `docker/daemon.json` inside the VM. Signed-off-by: Norio Nomura <[email protected]>
1 parent 18e18af commit 5267044

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

examples/docker.yaml

+21-2
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,31 @@ provision:
4848
curl -fsSL https://get.docker.com | sh
4949
# NOTE: you may remove the lines below, if you prefer to use rootful docker, not rootless
5050
systemctl disable --now docker
51-
apt-get install -y uidmap dbus-user-session
51+
apt-get install -y dbus-user-session fuse3 jq uidmap
5252
- mode: user
5353
script: |
5454
#!/bin/bash
5555
set -eux -o pipefail
5656
systemctl --user start dbus
57-
dockerd-rootless-setuptool.sh install
57+
systemctl list-unit-files --user docker.service &>/dev/null || dockerd-rootless-setuptool.sh install
5858
docker context use rootless
59+
60+
readonly config="$HOME/.config/docker/daemon.json"
61+
needs_restart=
62+
function set_docker_daemon_json() {
63+
function cat_config() { test -s "$config" && cat "$config" || echo "{}" ; }
64+
local -r current=$(cat_config | jq -r "$1 // empty")
65+
[ "$current" = "$2" ] && return 0
66+
mkdir -p $(dirname "$config") && cat_config | jq "$1 = ${2:-empty}" | (sleep 0 && tee "$config") && needs_restart=1
67+
}
68+
69+
# enable containerd image store
70+
set_docker_daemon_json '.features."containerd-snapshotter"' "$(
71+
[ "{{.Param.ContainerdImageStore}}" = "true" ] && echo 'true'
72+
)"
73+
74+
# restart docker to apply the new configuration
75+
[ -z "$needs_restart" ] || systemctl --user restart docker
5976
probes:
6077
- script: |
6178
#!/bin/bash
@@ -84,3 +101,5 @@ message: |
84101
docker context use lima-{{.Name}}
85102
docker run hello-world
86103
------
104+
param:
105+
ContainerdImageStore: false

0 commit comments

Comments
 (0)