This commit is contained in:
eric
2026-04-04 16:24:48 -05:00
parent a48db482a8
commit 8a1eebcb02
2 changed files with 46 additions and 5 deletions

View File

@@ -314,10 +314,26 @@ def main():
action="store_true",
help="Remove an existing container with the same name before running",
)
parser.add_argument(
"--rm",
dest="ephemeral",
action="store_true",
help="Ephemeral: delete container when it stops (disables auto-restart; not for production)",
)
parser.add_argument(
"--restart",
dest="restart_policy",
default="unless-stopped",
choices=("no", "always", "unless-stopped", "on-failure"),
help=(
"Docker/Podman restart policy when not using --rm (default: unless-stopped = "
"start after daemon reboot unless you docker stop'd it)"
),
)
parser.add_argument(
"--keep-container",
action="store_true",
help="Do not pass --rm to the runtime",
help="Legacy: containers are persistent by default; this flag is a no-op",
)
parser.add_argument(
"--dry-run",
@@ -408,8 +424,10 @@ def main():
]
if memory:
cmd.extend(["--memory", memory])
if not args.keep_container:
if args.ephemeral:
cmd.append("--rm")
elif args.restart_policy != "no":
cmd.extend(["--restart", args.restart_policy])
cmd.extend(dri_device_args)
cmd.append(image)
# Init applies read-only props in order; later ro.adb.secure=0 is ignored if adb.secure
@@ -472,6 +490,14 @@ def main():
subprocess.run(cmd, check=True)
print_color("Container started as {}".format(name), bcolors.GREEN)
if args.ephemeral:
print_color("Ephemeral (--rm): container is removed when it stops.", bcolors.YELLOW)
else:
print_color(
"Persistent: restart policy is {!r} (survives Docker daemon restart; "
"use `docker stop {}` to opt out of auto-start).".format(args.restart_policy, name),
bcolors.GREEN,
)
if args.diagnose:
local_post_diagnose(args.container, name, args.port, args.diagnose_settle)
if args.wait_tcp > 0:
@@ -490,8 +516,8 @@ def main():
print_color("Last logs from container {!r}:".format(name), bcolors.YELLOW)
subprocess.run([args.container, "logs", "--tail", "100", name], check=False)
print(
"\nIf the container already exited with --rm, logs are gone; re-run with "
"--keep-container (no --rm) to capture docker logs after a crash."
"\nIf the container already exited with --rm, logs are gone; re-run without --rm "
"for a persistent container."
)
print("ADB: adb connect 127.0.0.1:{}".format(args.port))
if effective_gpu_mode == "host":