Skip to content

Commit 62159c9

Browse files
authored
Merge pull request #210 from AkihiroSuda/more-examples
examples: add {docker,podman,singularity}.yaml
2 parents b06e4cb + 63a7dcd commit 62159c9

File tree

5 files changed

+189
-5
lines changed

5 files changed

+189
-5
lines changed

README.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Lima is expected to be used on macOS hosts, but can be used on Linux hosts as we
1313

1414
✅ Automatic port forwarding
1515

16-
✅ Built-in support for [containerd](https://containerd.io)
16+
✅ Built-in support for [containerd](https://containerd.io) ([Other container engines can be used too](./examples))
1717

1818
✅ Intel on Intel
1919

@@ -191,7 +191,7 @@ The current default spec:
191191
- ["What's my login password?"](#whats-my-login-password)
192192
- ["Does Lima work on ARM Mac?"](#does-lima-work-on-arm-mac)
193193
- ["Can I run non-Ubuntu guests?"](#can-i-run-non-ubuntu-guests)
194-
- ["Can I run other container engines such as Podman?"](#can-i-run-other-container-engines-such-as-podman)
194+
- ["Can I run other container engines such as Docker and Podman?"](#can-i-run-other-container-engines-such-as-docker-and-podman)
195195
- ["Can I run Lima with a remote Linux machine?"](#can-i-run-lima-with-a-remote-linux-machine)
196196
- ["Advantages compared to Docker for Mac?"](#advantages-compared-to-docker-for-mac)
197197
- [QEMU](#qemu)
@@ -231,10 +231,15 @@ An image has to satisfy the following requirements:
231231
- `newuidmap` and `newgidmap`
232232
- `apt-get`, `dnf`, `apk`, `pacman`, or `zypper` (if you want to contribute support for another package manager, run `git grep apt-get` to find out where to modify)
233233

234-
#### "Can I run other container engines such as Podman?"
235-
Yes, if you install it.
234+
#### "Can I run other container engines such as Docker and Podman?"
235+
Yes, any container engine should work with Lima.
236236

237-
containerd can be stopped with `systemctl --user disable --now containerd`.
237+
See examples:
238+
- [`./examples/docker.yaml`](./examples/docker.yaml)
239+
- [`./examples/podman.yaml`](./examples/podman.yaml)
240+
- [`./examples/singularity.yaml`](./examples/singularity.yaml)
241+
242+
The default Ubuntu image also contains LXD. Run`lima sudo lxc init` to set up LXD.
238243

239244
#### "Can I run Lima with a remote Linux machine?"
240245
Lima itself does not support connecting to a remote Linux machine, but [sshocker](https://github.com/lima-vm/sshocker),

examples/README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,26 @@
11
# Lima examples
22

3+
Default: [`default.yaml`](../pkg/limayaml/default.yaml) (Ubuntu, with containerd/nerdctl)
4+
5+
Distro:
6+
- [`alpine.yaml`](./alpine.yaml): Alpine Linux
7+
- [`archlinux.yaml`](./archlinux.yaml): Arch Linux
8+
- [`debian.yaml`](./debian.yaml): Debian GNU/Linux
9+
- [`fedora.yaml`](./fedora.yaml): Fedora
10+
- [`opensuse.yaml`](./opensuse.yaml): openSUSE Leap
11+
- [`ubuntu.yaml`](./ubuntu.yaml): Ubuntu (same as `default.yaml` but without bogus YAML lines)
12+
13+
Container engines:
14+
- [`docker.yaml`](./docker.yaml): Docker
15+
- [`podman.yaml`](./podman.yaml): Podman
16+
- [`k3s.yaml`](./k3s.yaml): k3s
17+
- [`singularity.yaml`](./singularity.yaml): Singularity
18+
- LXD is installed in the default Ubuntu template, so there is no `lxd.yaml`
19+
20+
Others:
21+
- [`vmnet.yaml`](./vmnet.yaml): enable [`vmnet.framework`](../docs/network.md)
22+
23+
## Usage
324
Run `limactl start fedora.yaml` to create a Lima instance named "fedora".
425

526
To open a shell, run `limactl shell fedora bash` or `LIMA_INSTANCE=fedora lima bash`.

examples/docker.yaml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Example to use Docker instead of containerd & nerdctl
2+
# $ limactl start ./docker.yaml
3+
# $ limactl shell docker docker run -it -v $HOME:$HOME --rm alpine
4+
5+
# Hint: To allow `docker` CLI on the host to connect to the Docker daemon running inside the guest,
6+
# add `NoHostAuthenticationForLocalhost yes` in ~/.ssh/config , and then run the following commands:
7+
# $ export DOCKER_HOST=ssh://localhost:60006
8+
# $ docker ...
9+
10+
# If ssh:// ... does not work, try the following commands:
11+
# $ ssh -f -N -p 60006 -i ~/.lima/_config/user -o NoHostAuthenticationForLocalhost=yes -L $HOME/docker.sock:/run/user/$(id -u)/docker.sock 127.0.0.1
12+
# $ export DOCKER_HOST=unix://$HOME/docker.sock
13+
# $ docker ...
14+
15+
images:
16+
# Hint: run `limactl prune` to invalidate the "current" cache
17+
- location: "https://cloud-images.ubuntu.com/hirsute/current/hirsute-server-cloudimg-amd64.img"
18+
arch: "x86_64"
19+
- location: "https://cloud-images.ubuntu.com/hirsute/current/hirsute-server-cloudimg-arm64.img"
20+
arch: "aarch64"
21+
mounts:
22+
- location: "~"
23+
writable: false
24+
- location: "/tmp/lima"
25+
writable: true
26+
ssh:
27+
localPort: 60006
28+
# Load ~/.ssh/*.pub in addition to $LIMA_HOME/_config/user.pub , for allowing DOCKER_HOST=ssh:// .
29+
# This option is enabled by default.
30+
# If you have an insecure key under ~/.ssh, do not use this option.
31+
loadDotSSHPubKeys: true
32+
# containerd is managed by Docker, not by Lima, so the values are set to false here.
33+
containerd:
34+
system: false
35+
user: false
36+
provision:
37+
- mode: system
38+
script: |
39+
#!/bin/bash
40+
set -eux -o pipefail
41+
command -v docker >/dev/null 2>&1 && exit 0
42+
export DEBIAN_FRONTEND=noninteractive
43+
curl -fsSL https://get.docker.com | sh
44+
# NOTE: you may remove the lines below, if you prefer to use rootful docker, not rootless
45+
systemctl disable --now docker
46+
apt-get install -y uidmap
47+
- mode: user
48+
script: |
49+
#!/bin/bash
50+
set -eux -o pipefail
51+
dockerd-rootless-setuptool.sh install
52+
docker context use rootless
53+
probes:
54+
- script: |
55+
#!/bin/bash
56+
set -eux -o pipefail
57+
if ! timeout 30s bash -c "until command -v docker >/dev/null 2>&1; do sleep 3; done"; then
58+
echo >&2 "docker is not installed yet"
59+
exit 1
60+
fi
61+
if ! timeout 30s bash -c "until pgrep rootlesskit; do sleep 3; done"; then
62+
echo >&2 "rootlesskit (used by rootless docker) is not running"
63+
exit 1
64+
fi
65+
hint: See "/var/log/cloud-init-output.log". in the guest

examples/podman.yaml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Example to use Podman instead of containerd & nerdctl
2+
# $ limactl start ./podman.yaml
3+
# $ limactl shell podman podman run -it --rm -v $HOME:$HOME:ro docker.io/library/alpine
4+
5+
# Hint: To allow `podman` CLI on the host to connect to the Podman daemon running inside the guest,
6+
# add `NoHostAuthenticationForLocalhost yes` in ~/.ssh/config , and then run the following commands:
7+
# $ export CONTAINER_HOST=ssh://$(id -un)@localhost:60906/run/user/$(id -u)/podman/podman.sock
8+
# $ export CONTAINER_SSHKEY=$HOME/.lima/_config/user
9+
# $ podman ...
10+
11+
# Hint: To allow `docker` CLI on the host to connect to the Podman daemon running inside the guest, run the following commands:
12+
# $ ssh -f -N -p 60906 -i ~/.lima/_config/user -o NoHostAuthenticationForLocalhost=yes -L $HOME/podman.sock:/run/user/$(id -u)/podman/podman.sock 127.0.0.1
13+
# $ export DOCKER_HOST=unix://$HOME/podman.sock
14+
# $ docker ...
15+
16+
images:
17+
# Image is set to impish (21.10) ahead of its GA, to pick up the newer version of podman dpkg
18+
# Hint: run `limactl prune` to invalidate the "current" cache
19+
- location: "https://cloud-images.ubuntu.com/impish/current/impish-server-cloudimg-amd64.img"
20+
arch: "x86_64"
21+
- location: "https://cloud-images.ubuntu.com/impish/current/impish-server-cloudimg-arm64.img"
22+
arch: "aarch64"
23+
mounts:
24+
- location: "~"
25+
writable: false
26+
- location: "/tmp/lima"
27+
writable: true
28+
ssh:
29+
localPort: 60906
30+
containerd:
31+
system: false
32+
user: false
33+
provision:
34+
- mode: system
35+
script: |
36+
#!/bin/bash
37+
set -eux -o pipefail
38+
command -v podman >/dev/null 2>&1 && exit 0
39+
export DEBIAN_FRONTEND=noninteractive
40+
apt-get update
41+
apt-get install -y podman
42+
- mode: user
43+
script: |
44+
#!/bin/bash
45+
set -eux -o pipefail
46+
systemctl --user enable --now podman.socket
47+
probes:
48+
- script: |
49+
#!/bin/bash
50+
set -eux -o pipefail
51+
if ! timeout 30s bash -c "until command -v podman >/dev/null 2>&1; do sleep 3; done"; then
52+
echo >&2 "podman is not installed yet"
53+
exit 1
54+
fi
55+
hint: See "/var/log/cloud-init-output.log". in the guest

examples/singularity.yaml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Example to use Singularity instead of containerd & nerdctl
2+
# $ limactl start ./singularity.yaml
3+
# $ limactl shell singularity singularity run -u -B $HOME:$HOME docker://alpine
4+
5+
# Fedora 34 provides Singularity 3.8.1 in the default dnf.
6+
# Ubuntu 21.04 does not seem to provide Singularity in the default apt.
7+
images:
8+
- location: "https://download.fedoraproject.org/pub/fedora/linux/releases/34/Cloud/x86_64/images/Fedora-Cloud-Base-34-1.2.x86_64.qcow2"
9+
arch: "x86_64"
10+
digest: "sha256:b9b621b26725ba95442d9a56cbaa054784e0779a9522ec6eafff07c6e6f717ea"
11+
firmware:
12+
legacyBIOS: true
13+
mounts:
14+
- location: "~"
15+
writable: false
16+
- location: "/tmp/lima"
17+
writable: true
18+
ssh:
19+
localPort: 62045
20+
containerd:
21+
system: false
22+
user: false
23+
provision:
24+
- mode: system
25+
script: |
26+
#!/bin/bash
27+
set -eux -o pipefail
28+
command -v singularity >/dev/null 2>&1 && exit 0
29+
dnf install -y singularity
30+
probes:
31+
- script: |
32+
#!/bin/bash
33+
set -eux -o pipefail
34+
if ! timeout 30s bash -c "until command -v singularity >/dev/null 2>&1; do sleep 3; done"; then
35+
echo >&2 "singularity is not installed yet"
36+
exit 1
37+
fi
38+
hint: See "/var/log/cloud-init-output.log". in the guest

0 commit comments

Comments
 (0)