Skip to content

Instantly share code, notes, and snippets.

@flavianmissi
Last active April 5, 2022 12:53
Show Gist options
  • Save flavianmissi/23a5ea1295404d0da96c2d8be1dbcc0d to your computer and use it in GitHub Desktop.
Save flavianmissi/23a5ea1295404d0da96c2d8be1dbcc0d to your computer and use it in GitHub Desktop.
lima vm running podman 4 on fedora
# Example to use Podman instead of containerd & nerdctl
# $ limactl start ./podman.yaml
# $ limactl shell podman podman run -it -v $HOME:$HOME --rm docker.io/library/alpine
# To run `podman` on the host (assumes podman-remote is installed):
# $ export CONTAINER_HOST=$(limactl list podman --format 'unix://{{.Dir}}/sock/podman.sock')
# $ podman --remote ...
# To run `docker` on the host (assumes docker-cli is installed):
# $ export DOCKER_HOST=$(limactl list podman --format 'unix://{{.Dir}}/sock/podman.sock')
# $ docker ...
# This example requires Lima v0.8.0 or later
images:
- location: "https://download.fedoraproject.org/pub/fedora/linux/releases/35/Cloud/x86_64/images/Fedora-Cloud-Base-35-1.2.x86_64.qcow2"
arch: "x86_64"
digest: "sha256:fe84502779b3477284a8d4c86731f642ca10dd3984d2b5eccdf82630a9ca2de6"
- location: "https://download.fedoraproject.org/pub/fedora/linux/releases/35/Cloud/aarch64/images/Fedora-Cloud-Base-35-1.2.aarch64.qcow2"
arch: "aarch64"
digest: "sha256:c71f2e6ce75b516d565e2c297ea9994c69b946cb3eaa0a4bbea400dbd6f59ae6"
mounts:
- location: "~"
- location: "/tmp/lima"
writable: true
containerd:
system: false
user: false
provision:
- mode: system
script: |
#!/bin/bash
set -eux -o pipefail
command -v podman >/dev/null 2>&1 && exit 0
dnf -y copr enable rhcontainerbot/podman4
dnf -y install podman
- mode: user
script: |
#!/bin/bash
set -eux -o pipefail
systemctl --user enable --now podman.socket
probes:
- script: |
#!/bin/bash
set -eux -o pipefail
if ! timeout 30s bash -c "until command -v podman >/dev/null 2>&1; do sleep 3; done"; then
echo >&2 "podman is not installed yet"
exit 1
fi
hint: See "/var/log/cloud-init-output.log". in the guest
hostResolver:
enabled: false # avoid networking issues from inside vm
portForwards:
- guestSocket: "/run/user/{{.UID}}/podman/podman.sock"
hostSocket: "{{.Dir}}/sock/podman.sock"
message: |
To run `podman` on the host (assumes podman-remote is installed), run the following commands:
------
podman system connection add lima "unix://{{.Dir}}/sock/podman.sock"
podman system connection default lima
podman{{if eq .HostOS "linux"}} --remote{{end}} run quay.io/podman/hello
------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment