Add helper scripts to run podman as podman user inside the podman container #47
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Setup
I'm running a non privileged gitlab-runner (docker executor) with a podman host. Podman is configured rootless and the socket runs with systemd under the user gitlab-runner. Subids are configured for that user.
Problem description
Using the podman image inside a gitlab ci job doesn't work because the container uses the user root. For Rootless Podman running rootless Podman the container should run with user podman as described in this blog post. However I still want to run the container as root because sometimes I need to install additional packages to complete the ci job. The downside here is that I always need to use
runuser -u podman -- podman infoProposed solution
To simplify the rootless podman call this PR includes a helper script called
podman-rootlessinto the podman image which allows to run the podman command as podman user.In the CI pipeline I can simply run
podman-rootless infonow.There's another helper script
run-as-podmanto run arbitrary commands as user podman. For example to create new directories run-as-podman mkdir /path/.