Skip to content

Commit

Permalink
fix: Close docker client when stopping the docker container (testcont…
Browse files Browse the repository at this point in the history
…ainers#380)

Fixes the following warning

```
sys:1: ResourceWarning: unclosed <socket.socket fd=7, family=AddressFamily.AF_UNIX, type=SocketKind.SOCK_STREAM, proto=0, raddr=/Users/rodrigo/.docker/run/docker.sock>
```
 Related to testcontainers#379

Co-authored-by: David Ankin <[email protected]>
  • Loading branch information
rstcruzo and alexanderankin authored Mar 9, 2024
1 parent cd90aa7 commit efb1683
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions core/testcontainers/core/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ def start(self) -> "DockerContainer":

def stop(self, force=True, delete_volume=True) -> None:
self._container.remove(force=force, v=delete_volume)
self.get_docker_client().client.close()

def __enter__(self) -> "DockerContainer":
return self.start()
Expand Down

0 comments on commit efb1683

Please sign in to comment.