From 6addda22034156e561bacfa0e219f945ed4fa3bc Mon Sep 17 00:00:00 2001 From: Christian Blichmann Date: Wed, 3 Nov 2021 16:49:17 +0100 Subject: [PATCH] Add override for container tool in `dev_container` script This change allows to override the command line tool that is used to start the dev container in the `tools/dev_container` script. The Makefile for creating the dev container uses the `DOCKER` env var to implement this, so this is used here as well. Rationale: Googlers are advised to not install Docker (go/dont-install-docker) and to use Podman instead. If the `DOCKER` variable is unset, the script will try to use Docker first and podman. Change-Id: I33bc8e4af632fa982406e838e762572407ccdc22 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3259939 Reviewed-by: Dennis Kempin Tested-by: kokoro Commit-Queue: Christian Blichmann --- tools/dev_container | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tools/dev_container b/tools/dev_container index b98d73bccf..d5f0d13859 100755 --- a/tools/dev_container +++ b/tools/dev_container @@ -6,7 +6,7 @@ set -e cd "$(dirname $0)/.." -docker_args=( +cli_args=( --rm --volume $(pwd):/workspace:rw --device /dev/net/tun @@ -17,11 +17,15 @@ docker_args=( # Enable interactive mode when running in an interactive terminal. if [ -t 1 ]; then - docker_args+=(-it) + cli_args+=(-it) fi -docker run \ - ${docker_args[@]} \ +# Allow to override the container CLI tool, similar to the Makefile. Try +# "docker" first and fall back to "podman". +DOCKER=${DOCKER:-$(which docker || which podman)} + +"${DOCKER}" run \ + ${cli_args[@]} \ gcr.io/crosvm-packages/crosvm_dev:$(cat tools/impl/dev_container/version) \ "$@"