Skip to content

fix(env): stop or kill docker containers on cleanup#869

Open
dannyward630 wants to merge 1 commit into
SWE-agent:mainfrom
dannyward630:codex/docker-cleanup-stop-or-kill
Open

fix(env): stop or kill docker containers on cleanup#869
dannyward630 wants to merge 1 commit into
SWE-agent:mainfrom
dannyward630:codex/docker-cleanup-stop-or-kill

Conversation

@dannyward630

Copy link
Copy Markdown

Summary

Fixes #797.

DockerEnvironment.cleanup() currently falls back from docker stop to docker rm -f. That makes cleanup force removal when stop fails, even though removal is already controlled by the configured run_args (--rm by default) and users may intentionally omit --rm to keep stopped containers for debugging.

This changes the fallback to docker kill, so cleanup attempts to terminate the container while leaving removal policy to Docker's --rm behavior or the user's run_args override.

Validation

  • .venv/bin/python -m pytest tests/environments/test_docker.py -k 'config_defaults or cleanup_stops_or_kills'
    • 1 passed, 2 skipped, 20 deselected on this machine because Docker/Podman are not available
  • .venv/bin/ruff check src/minisweagent/environments/docker.py tests/environments/test_docker.py
  • git diff --check

@dannyward630
dannyward630 marked this pull request as ready for review June 18, 2026 23:03
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

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.

Why use || between stop and rm when cleanup a docker environment?

1 participant