Skip to content

🙌 OpenHands: AI-Driven Development

stopped container to prevent port issues. (#2447)

மனோஜ்குமார் பழனிச்சாமிac6ef8e59d86
diff --git a/opendevin/runtime/docker/ssh_box.py b/opendevin/runtime/docker/ssh_box.py
index 942a2be12e..6cf0100f50 100644
--- a/opendevin/runtime/docker/ssh_box.py
+++ b/opendevin/runtime/docker/ssh_box.py
@@ -746,14 +746,14 @@ class DockerSSHBox(Sandbox):
containers = self.docker_client.containers.list(all=True)
for container in containers:
try:
- if (
- container.name.startswith(self.container_name)
- and not config.persist_sandbox
- ):
- # only remove the container we created
- # otherwise all other containers with the same prefix will be removed
- # which will mess up with parallel evaluation
- container.remove(force=True)
+ if container.name.startswith(self.container_name):
+ if config.persist_sandbox:
+ container.stop()
+ else:
+ # only remove the container we created
+ # otherwise all other containers with the same prefix will be removed
+ # which will mess up with parallel evaluation
+ container.remove(force=True)
except docker.errors.NotFound:
pass
self.docker_client.close()