diff --git a/README.md b/README.md index 8956ac2..f4f0e50 100644 --- a/README.md +++ b/README.md @@ -121,6 +121,21 @@ redroid/redroid:13.0.0_mindthegapps_houdini_magisk Headless servers have **no screen** to approve the USB debugging RSA dialog. Always pass **`--adb-insecure`** so boot props disable ADB RSA checks and apply **before** the Pixel user profile (`androidboot.adb.secure=0`, `ro.adb.secure=0`, `ro.secure=0`, `ro.debuggable=1`). **Do not expose the ADB port on a public network.** +### Persist after reboot (default) + +By default **`run_redroid.py` does not pass `--rm`**: the container stays on disk when it stops, and uses **`--restart unless-stopped`** so **Docker/Podman will start it again after the daemon or host reboots** (unless you ran `docker stop `). + +- **Always restart** even after explicit stop: `--restart always` +- **No auto-restart** but still keep the container (no `--rm`): `--restart no` +- **One-off / dev only** (old behavior, removed on stop): pass **`--rm`** + +On Ubuntu, ensure the engine starts on boot: + +```bash +sudo systemctl enable docker --now +# or: sudo systemctl enable podman.socket --now # if you use Podman rootful similarly +``` + ```bash python run_redroid.py \ --image redroid/redroid:13.0.0_mindthegapps_houdini_magisk \ @@ -186,7 +201,7 @@ The `shell` subcommand is a minimal pseudo-shell only; for a full TTY, use norma This means **nothing is listening on the host port** (not the same as `unauthorized`). Typical causes: -1. **Container exited** — especially with `--rm`, a crash removes the instance. Run `docker ps -a` and `docker logs` on a **non-`--rm`** run (`--keep-container`) to see init/EGL errors. +1. **Container exited** — if you used **`--rm`**, a crash removes the instance. By default the container is **kept**; use `docker ps -a` and `docker logs` to inspect. Ensure **`--restart`** is not `no` if you want auto-start after reboot. 2. **`androidboot.redroid_gpu_mode=host`** — Mesa/EGL or DRI inside the guest can fail on some hosts; Android never reaches **adbd**. **Workaround:** force software rendering: ```bash python run_redroid.py ... --adb-insecure --gpu-mode guest diff --git a/run_redroid.py b/run_redroid.py index 3a8195f..b145261 100644 --- a/run_redroid.py +++ b/run_redroid.py @@ -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":