crosvm/tools/dev_container
Christian Blichmann 6addda2203 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 <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Christian Blichmann <cblichmann@google.com>
2021-11-05 08:40:43 +00:00

31 lines
775 B
Bash
Executable file

#!/usr/bin/env bash
# Copyright 2021 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
set -e
cd "$(dirname $0)/.."
cli_args=(
--rm
--volume $(pwd):/workspace:rw
--device /dev/net/tun
--device /dev/kvm
--volume /dev/log:/dev/log
--privileged
)
# Enable interactive mode when running in an interactive terminal.
if [ -t 1 ]; then
cli_args+=(-it)
fi
# 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) \
"$@"