Skip to content

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

Description

@hankeke303

Describe the bug

Whenever I finish running mini-swe-agent, it consistently leaves behind a large number of exited Docker containers.
This appears to be because the commands within the cleanup method of the DockerEnvironment class use the logical OR operator (||) between docker stop and docker rm, resulting in the containers not being removed after their usage is complete.
Is this the intended behavior?

def cleanup(self):
"""Stop and remove the Docker container."""
if getattr(self, "container_id", None) is not None: # if init fails early, container_id might not be set
cmd = f"(timeout 60 {self.config.executable} stop {self.container_id} || {self.config.executable} rm -f {self.container_id}) >/dev/null 2>&1 &"
subprocess.Popen(cmd, shell=True)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions