diff --git a/podman/Containerfile b/podman/Containerfile index 733b290..2842401 100644 --- a/podman/Containerfile +++ b/podman/Containerfile @@ -99,5 +99,9 @@ RUN mkdir -p /var/lib/shared/overlay-images \ touch /var/lib/shared/vfs-images/images.lock && \ touch /var/lib/shared/vfs-layers/layers.lock +# Rootless helper scripts +COPY podman-rootless /usr/local/bin/ +COPY run-as-podman /usr/local/bin/ + ENV _CONTAINERS_USERNS_CONFIGURED="" \ BUILDAH_ISOLATION=chroot diff --git a/podman/README.md b/podman/README.md index 4e9ad1c..d0c6510 100644 --- a/podman/README.md +++ b/podman/README.md @@ -53,6 +53,17 @@ the fuse kernel module has not been loaded on your host system. Use the command module and then run the container image. To enable this automatically at boot time, you can add a configuration file to `/etc/modules.load.d`. See `man modules-load.d` for more details. +## Sample Usage Rootless Podman running Rootless Podman +If you set up [rootless podman](https://github.com/containers/podman/blob/main/docs/tutorials/rootless_tutorial.md) +on your system, and you want to run +[Rootless Podman running Rootless Podman](#blog-post-with-details) +then you have to run the podman CLI with user podman to correctly map user and group id. +However, in special environments (e.g. in CI environments) it's sometimes helpful to run the inner container as root +user to install packages, prepare the build etc. +To run the podman CLI in the inner container with user podman use +`podman-rootless `. +If you need to to run an arbitrary command with user podman use `run-as-podman `. + ### Blog Post with Details Dan Walsh wrote a blog post on the [Enable Sysadmin](https://www.redhat.com/sysadmin/) site titled [How to use Podman inside of a container](https://www.redhat.com/sysadmin/podman-inside-container). In it, he details how to use these images as a rootful and as a rootless user. Please refer to this blog for more detailed information. diff --git a/podman/podman-rootless b/podman/podman-rootless new file mode 100755 index 0000000..63f1218 --- /dev/null +++ b/podman/podman-rootless @@ -0,0 +1,2 @@ +#!/bin/bash +runuser -u podman -- podman "$@" diff --git a/podman/run-as-podman b/podman/run-as-podman new file mode 100755 index 0000000..2835710 --- /dev/null +++ b/podman/run-as-podman @@ -0,0 +1,2 @@ +#!/bin/bash +runuser -u podman -- "$@"