Browse Source

stopped container to prevent port issues. (#2447)

மனோஜ்குமார் பழனிச்சாமி 1 year ago
parent
commit
ac6ef8e59d
1 changed files with 8 additions and 8 deletions
  1. 8 8
      opendevin/runtime/docker/ssh_box.py

+ 8 - 8
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()