Skip to content

Instantly share code, notes, and snippets.

@jwhb
Last active February 1, 2022 12:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jwhb/febeb3d90790c08d5dddc6eba0c2f06d to your computer and use it in GitHub Desktop.
Save jwhb/febeb3d90790c08d5dddc6eba0c2f06d to your computer and use it in GitHub Desktop.
Rootful Podman on RockyLinux for lima-vm
# 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://dl.rockylinux.org/pub/rocky/8.5/images/Rocky-8-GenericCloud-8.5-20211114.2.x86_64.qcow2"
arch: "x86_64"
digest: "sha256:c23f58f26f73fb9ae92bfb4cf881993c23fdce1bbcfd2881a5831f90373ce0c8"
- location: "https://dl.rockylinux.org/pub/rocky/8.5/images/Rocky-8-GenericCloud-8.5.20211114.1.aarch64.qcow2"
arch: "aarch64"
digest: "sha256:f13cfa7b5e449cc165181a1efbea5b1cdce73ef6a5d6bb24c22b50f67f1f8fe2"
mounts:
- location: "~"
- location: "/tmp/lima"
writable: true
firmware:
legacyBIOS: 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 install -y podman
mkdir -p /etc/systemd/system/podman.socket.d
echo -e "[Socket]\nSocketUser=$LIMA_CIDATA_UID" > /etc/systemd/system/podman.socket.d/socketuser.conf
systemctl daemon-reload
systemctl 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
portForwards:
- guestSocket: "/run/podman/podman.sock"
hostSocket: "{{.Dir}}/sock/podman.sock"
message: |
To run `podman` on the host (assumes podman-remote is installed):
$ export CONTAINER_HOST=unix://{{.Dir}}/sock/podman.sock
$ podman{{if eq .HostOS "linux"}} --remote{{end}} ...
To permanently configure the podman backend:
$ podman-remote system connection add --default lima unix://{{.Dir}}/sock/podman.sock
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment