Skip to content

sandbox doesn't run the initial custom command after system restart #1805

Description

@ninja18

Agent Diagnostic

  • Docker driver overrides the image ENTRYPOINT with the supervisor binary and hardcodes its command to sleep
    infinity (crates/openshell-driver-docker/src/lib.rs:1759-1762, :1669-1671).
  • Workload passed via openshell sandbox create ... -- /app/entrypoint.sh is not stored in the sandbox spec; CLI
    runs it as a one-shot SSH exec session after the sandbox is Ready (crates/openshell-cli/src/run.rs:2169,
    ssh.rs:399).
  • On gateway restart after reboot, resume_persisted_sandboxes() (crates/openshell-server/src/lib.rs:344) resumes
    the container via a bare docker start (driver-docker/src/lib.rs:719,738), re-running only PID 1 (supervisor →
    sleep infinity).
  • The original -- exec command is never persisted or replayed, so the workload does not return.
  • ps aux confirms: first run shows bash /app/entrypoint.sh + openclaw; after restart only sleep infinity remains.
  • Net: any command given to sandbox create is ephemeral to the CLI process and lost across gateway/host restarts,
    even though the sandbox reports Ready/Running.

Description

Disclaimer: This could be a bug or feature request or a documentation update for proper usage.

I created a sandbox using my Dockerfile

openshell sandbox create \
--from "$INSTALL_DIR" \
--name "$SANDBOX_NAME" \
--provider "$PROVIDER_NAME" \
--policy "$POLICY_FILE" \
--no-tty \
--no-auto-providers \
--forward "$GATEWAY_PORT" \
-- /app/entrypoint.sh

I gave the my entrypoint.sh here because openshell defaults to the supervisor as the container's entrypoint. This script is run on the first run. But after the system restarts and the sandbox is relaunched. This command /app/entrypoint.sh is not run.
Openshell treats the command passed during sandbox creation as one off session command. But I want it to persist this and run it on every restart.

Workaround:
I can create a systemd service and do openshell sandbox exec sandbox_name--no-tty -- /app/entrypoint.sh once the gateway and sandbox is ready on system restart. I was anyway planning to do this because the port forward passed in openshell sandbox create command is also not coming up after system restart.

The ps aux results before and after restart confirm that the command is not run
ps aux results on first run:
Image

ps aux after system restart:
Image

I don't know if this is intentional but while creating a custom sandbox, the sandbox is not useful if the user's entrypoint is not run when the sandbox restarts. Also I couldn't find any documentation saying that the command passed during sandbox creation is temporary.

Reproduction Steps

  1. Run sandbox from custom image with a entrypoint command
openshell sandbox create \
--from "$INSTALL_DIR" \
--name "$SANDBOX_NAME" \
--no-tty \
--forward "$GATEWAY_PORT" \
-- /app/entrypoint.sh
  1. Restart the system
  2. The openshell gateway and sandbox is ready but the entrypoint command is not run

Environment

  • OS: Ubuntu 19
  • Docker: 29.4.1
  • Openshell: v0.0.54

Logs

Agent-First Checklist

  • I pointed my agent at the repo and had it investigate this issue
  • I loaded relevant skills (e.g., debug-openshell-cluster, debug-inference, openshell-cli)
  • My agent could not resolve this — the diagnostic above explains why

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicateThis issue or pull request already exists

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions