Skip to content

fix: clean up Docker isolation containers by default#141

Merged
konard merged 4 commits into
mainfrom
issue-140-55c0984f3705
Jun 24, 2026
Merged

fix: clean up Docker isolation containers by default#141
konard merged 4 commits into
mainfrom
issue-140-55c0984f3705

Conversation

@konard

@konard konard commented Jun 24, 2026

Copy link
Copy Markdown
Member

Fixes #140.

Summary

$ --isolated docker now cleans up Docker containers by default after the container command finishes while keeping the host-side session log. The old --auto-remove-docker-container flag remains supported as a compatibility alias for the always-cleanup policy.

What changed

  • Added explicit Docker cleanup policies in both JavaScript and Rust:
    • --always-cleanup-container (default behavior)
    • --keep-container
    • --keep-container-on-fail
    • --auto-remove-docker-container compatibility alias
  • Removed daemon-level docker run --rm usage so detached logging can drain and capture the exit code before cleanup.
  • Added detached cleanup watchers that follow docker logs -f, capture docker inspect .State.ExitCode, write the log footer, then remove containers according to policy.
  • Added attached-mode log teeing so attached Docker output still reaches the host log file before explicit cleanup.
  • Threaded cleanup metadata through status/history records and nested JS isolation command construction.
  • Added JS changeset and Rust changelog fragment for the release workflows.

Reproduction

Before this change, detached Docker sessions without --auto-remove-docker-container left exited containers behind indefinitely. Attached Docker sessions used --rm and inherited stdio, so they could not reliably preserve a host log while also letting the wrapper decide cleanup policy.

After this change:

$ --isolated docker --detached --image alpine -- echo test
# container exits, logs are drained, exit code footer is written, container is removed

$ --isolated docker --detached --image alpine --keep-container -- echo test
# exited container is preserved for inspection

$ --isolated docker --detached --image alpine --keep-container-on-fail -- sh -c 'exit 7'
# failed container is preserved for inspection

Tests

  • cd js && bun run check
  • cd js && bun run test
  • bun test ./js/test/docker-autoremove.js
  • bun test ./js/test/args-parser.js ./js/test/args-parser-docker-cleanup.js ./js/test/command-builder-docker-cleanup.js
  • cargo fmt --manifest-path rust/Cargo.toml --all -- --check
  • cargo clippy --manifest-path rust/Cargo.toml --all-targets --all-features
  • cargo test --manifest-path rust/Cargo.toml --all-features --verbose
  • bash scripts/check-mjs-syntax.sh
  • node scripts/check-test-parity.mjs
  • node scripts/validate-changeset.mjs

No screenshots are included because this is CLI/runtime behavior.

Release

  • js/.changeset/docker-container-cleanup.md (minor)
  • rust/changelog.d/141.md (bump: minor)

Adding .gitkeep for PR creation (default mode).
This file will be removed when the task is complete.

Issue: #140
@konard konard self-assigned this Jun 24, 2026
@konard konard changed the title [WIP] $ --isolated docker: remove container filesystem when the command finishes (keep the log), with opt-out to keep it for investigation fix: clean up Docker isolation containers by default Jun 24, 2026
@konard konard marked this pull request as ready for review June 24, 2026 11:09
@konard

konard commented Jun 24, 2026

Copy link
Copy Markdown
Member Author

Working session summary

Done. PR #141 is updated, ready, and clean:

#141

Head commit is ea4e574. Fresh CI on that head passed:

Implemented the Docker cleanup behavior from issue #140, including default cleanup after command completion, host log preservation, --keep-container, --always-cleanup-container, --keep-container-on-fail, and compatibility for --auto-remove-docker-container. I also fixed the initial CI file-size failure by splitting Rust Docker cleanup helpers into rust/src/lib/docker_cleanup.rs.

Local checks passed, including JS check/test, Rust fmt/clippy/test, file-size, test parity, changeset validation, and diff whitespace check. Working tree is clean.


This summary was automatically extracted from the AI working session output.

@konard

konard commented Jun 24, 2026

Copy link
Copy Markdown
Member Author

🤖 Solution Draft Log

This log file contains the complete execution trace of the AI solution draft process.

💰 Cost estimation:

  • Model: GPT-5.5
  • Provider: OpenAI
  • Public pricing estimate: $24.832279

📊 Context and tokens usage:

  • 682.1K / 200K (341%) input tokens, 70.6K / 128K (55%) output tokens

Total: (682.1K + 14.8M cached) input tokens, 70.6K output tokens, $24.832279 cost

🤖 Models used:

  • Tool: OpenAI Codex
  • Requested: gpt-5.5
  • Thinking level: max (~31999 tokens)
  • Model: GPT-5.5 (gpt-5.5)

📎 Log file uploaded as Repository (2 chunks) (106559KB)


Now working session is ended, feel free to review and add any feedback on the solution draft.

@konard

konard commented Jun 24, 2026

Copy link
Copy Markdown
Member Author

✅ Ready to merge

This pull request is now ready to be merged:

  • All CI checks have passed
  • No merge conflicts
  • No pending changes

Monitored by hive-mind with --auto-restart-until-mergeable flag

@konard konard merged commit dad6cf7 into main Jun 24, 2026
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

$ --isolated docker: remove container filesystem when the command finishes (keep the log), with opt-out to keep it for investigation

1 participant