There are two places where file descriptors are being leaked , at least with python 3.8:
_get_raw_response_socket(): in case of Unix sockets, additional referencing seems to stop them from being closed
- When
DockerClient is not used as a context manager it does not call close() on the api session object.
I have managed to work around with:
class FixedAPIClient(docker.APIClient):
def _get_raw_response_socket(self, response):
sock = super()._get_raw_response_socket(response)
if self.base_url.startswith('http+docker://'):
sock._response = None
return sock
class FixedDockerClient(docker.DockerClient):
def __init__(self, *args, **kwargs):
self.api = FixedAPIClient(*args, **kwargs)
def __del__(self):
try:
if self.api:
self.api.close()
except AttributeError:
pass
Our setup is quite complex. If you believe this should not happen and it is a corner case I will try to come up with a minimal example.
There are two places where file descriptors are being leaked , at least with python 3.8:
_get_raw_response_socket():in case of Unix sockets, additional referencing seems to stop them from being closedDockerClientis not used as a context manager it does not callclose()on the api session object.I have managed to work around with:
Our setup is quite complex. If you believe this should not happen and it is a corner case I will try to come up with a minimal example.