From f97e6293de1491e75b0798bddf4b0532c7f92bd2 Mon Sep 17 00:00:00 2001 From: Julien Olivain Date: Sat, 1 Jun 2024 12:04:17 +0200 Subject: [PATCH] utils/docker-run: set podman userns option in environment Commit 9a629f5 "utils/docker-run: allow running with Podman" added an option on system providing the podman command. This case is mainly for Fedora systems. Fedora repositories have a podman-docker package, that provides the docker command for compatibility. See [1]. In that case, invoking "docker" redirects to podman. When this package is installed on a Fedora system, both the docker and podman commands are available. Since the docker command is checked before podman, the --userns option is not passed in that case. This brings "permission denied" errors. Other cases are also possible, like a host system providing the real Docker alongside a podman installation. In such a case, to avoid unexpected change of behavior of the docker-run script, the original search order is preserved (search for "docker" first, then "podman"). This commit changes the way the podman user namespace mode is set. Rather than adding the "--userns=keep-id" command line option only in the podman case, it is globally set using the PODMAN_USERNS=keep-id environment variable [2]. Doing so makes sure that the variable will be consumed by the "docker" compatibility command, and just ignored by the real "docker" implementation. [1] https://packages.fedoraproject.org/pkgs/podman/podman-docker/ [2] https://docs.podman.io/en/latest/markdown/podman-run.1.html Signed-off-by: Julien Olivain Signed-off-by: Yann E. MORIN --- utils/docker-run | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/utils/docker-run b/utils/docker-run index 3dcabe2718..1adb02d74e 100755 --- a/utils/docker-run +++ b/utils/docker-run @@ -29,11 +29,16 @@ declare -a mountpoints=( "$(pwd)" ) +# We use the PODMAN_USERNS environment variable rather than using the +# --userns command line argument because Fedora system may have the +# podman-docker package installed, providing the "docker" +# compatibility command. +export PODMAN_USERNS="keep-id" + if command -v docker >/dev/null; then DOCKER="docker" elif command -v podman >/dev/null; then DOCKER="podman" - docker_opts+=( --userns=keep-id ) else echo "ERROR: Neither docker nor podman available!" >&2 exit 1