commit d481cd356ddacc592fdb0a9fa024a7adcdcecf01 Author: Nicolas Massé Date: Tue Jun 10 20:46:15 2025 +0200 initial commit diff --git a/Containerfile b/Containerfile new file mode 100644 index 0000000..da63203 --- /dev/null +++ b/Containerfile @@ -0,0 +1,9 @@ +FROM quay.io/fedora/fedora:42 + +RUN dnf install -y qemu-user-static \ + && dnf clean all + +ADD container-entrypoint / + +ENTRYPOINT ["/container-entrypoint"] +CMD [] diff --git a/README.md b/README.md new file mode 100644 index 0000000..8aaca70 --- /dev/null +++ b/README.md @@ -0,0 +1,22 @@ +# qemu-user-static container image + +## Build + +```sh +git clone https://github.com/nmasse-itix/qemu-user-static.git +cd qemu-user-static +sudo podman build -t localhost/qemu-user-static:latest . +``` + +## Run + +```sh +sudo podman run -it --privileged --security-opt label=filetype:container_file_t --security-opt label=level:s0 --security-opt label=type:spc_t localhost/qemu-user-static:latest +``` + +## Test + +```sh +sudo podman run -it --rm --platform linux/arm64/v8 docker.io/library/alpine:latest +``` + diff --git a/container-entrypoint b/container-entrypoint new file mode 100755 index 0000000..05ab3ea --- /dev/null +++ b/container-entrypoint @@ -0,0 +1,20 @@ +#!/bin/sh + +set -Eeuo pipefail + +if [ ! -d /proc/sys/fs/binfmt_misc ]; then + echo "No binfmt support in the kernel." + echo " Try: '/sbin/modprobe binfmt_misc' from the host" + exit 1 +fi + +if [ ! -f /proc/sys/fs/binfmt_misc/register ]; then + echo "Mounting /proc/sys/fs/binfmt_misc..." + mount binfmt_misc -t binfmt_misc /proc/sys/fs/binfmt_misc +fi + +echo "Cleaning up..." +find /proc/sys/fs/binfmt_misc -type f -name 'qemu-*' -exec sh -c 'echo -1 > {}' \; + +echo "Registering..." +exec /usr/lib/systemd/systemd-binfmt