From 9a629f5129d652960b203e53685aea24a4dd86a1 Mon Sep 17 00:00:00 2001 From: Fiona Klute Date: Fri, 31 May 2024 12:44:25 +0200 Subject: [PATCH] utils/docker-run: allow running with Podman Podman is command line compatible with Docker, there's no need to require contributors to install Docker to run checks before sending patches. The additional "--userns=keep-id" option is necessary because unlike Docker Podman creates a user namespace for containers by default. Without keep-id the repository and pre-existing output files belong to root inside the container namespace, breaking writes, certain Git safety checks, and possibly all access (if the user is using a strict umask). Signed-off-by: Fiona Klute Signed-off-by: Yann E. MORIN --- utils/docker-run | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/utils/docker-run b/utils/docker-run index 79694474c1..3dcabe2718 100755 --- a/utils/docker-run +++ b/utils/docker-run @@ -29,6 +29,16 @@ declare -a mountpoints=( "$(pwd)" ) +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 +fi + # curl lists (and recognises and uses) other types of *_proxy variables, # but only those make sense for Buildroot: for env in all_proxy http_proxy https_proxy ftp_proxy no_proxy; do @@ -84,4 +94,4 @@ if tty -s; then docker_opts+=( -t ) fi -exec docker run "${docker_opts[@]}" "${IMAGE}" "${@}" +exec ${DOCKER} run "${docker_opts[@]}" "${IMAGE}" "${@}"