dev_container: Keep alive with 'sleep infinity'

We run a neverending command in the container to keep it alive in the
background.
By default, this would be bash, which does the job when --tty is
specified. But we no longer do that all the time.

Instead we can use sleep, which does not rely on such tricks.

BUG=b:233913455
TEST=./tools/dev_container true

Change-Id: I2d04aabbef6b670daf6b94fdc2c65c7bd759c61b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3669682
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
This commit is contained in:
Dennis Kempin 2022-05-25 21:11:13 +00:00
parent ac65c32e6e
commit c2292ef52f

View file

@ -109,8 +109,9 @@ def main(
container_id = None container_id = None
if not container_id: if not container_id:
# Run neverending sleep to keep container alive while we 'docker exec' commands.
container_id = docker( container_id = docker(
f"run --detach --name {CONTAINER_NAME}", *tty_args, *docker_args f"run --detach --name {CONTAINER_NAME}", *docker_args, "sleep infinity"
).stdout() ).stdout()
print(f"Started dev-container ({container_id}).") print(f"Started dev-container ({container_id}).")
else: else: