Jelajahi Sumber

utils/docker-run: allow explicitly setting of docker/podman/...

Currently, our docker-run helper will decide on its own whether it
should use docker (preferred) or podman (fallback), as introduced in
9a629f5129d6 (utils/docker-run: allow running with Podman). In case
both are installed, it is not possible to exercise the podman case.
Often, 'docker' is just an alias for 'podman' when both are available,
but this is not always true - and in the latter case, the user needs to
be able to choose which one they want.

Allow the user to force the one to use, by setting the BR2_DOCKER
environment variable. If that is set and it doesn't exist, exit with
an explicit error message (rather than relying on the failure when
eventually exec-ing the specified command).

Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
Cc: Ricardo Martincoski <ricardo.martincoski@datacom.com.br>
Cc: Julien Olivain <ju.o@free.fr>
Cc: Fiona Klute <fiona.klute@gmx.de>
Reviewed-by: Fiona Klute (WIWA) <fiona.klute@gmx.de>
Signed-off-by: Arnout Vandecappelle <arnout@mind.be>
Yann E. MORIN 5 bulan lalu
induk
melakukan
25b6a6ecee
1 mengubah file dengan 8 tambahan dan 1 penghapusan
  1. 8 1
      utils/docker-run

+ 8 - 1
utils/docker-run

@@ -35,7 +35,14 @@ declare -a mountpoints=(
 # compatibility command.
 export PODMAN_USERNS="keep-id"
 
-if command -v docker >/dev/null; then
+if [ "${BR2_DOCKER}" ]; then
+    if command -v "${BR2_DOCKER}" >/dev/null; then
+        DOCKER="${BR2_DOCKER}"
+    else
+        printf 'ERROR: Command "%s" (from env BR2_DOCKER) not found.\n' "${BR2_DOCKER}" >&2
+        exit 1
+    fi
+elif command -v docker >/dev/null; then
     DOCKER="docker"
 elif command -v podman >/dev/null; then
     DOCKER="podman"