docker.from_env requires the Docker socket to be available, while previously it didn't (it would just default to 1.3.5).After upgrading from docker-py 4.2.2 -> 4.3.1, I start getting errors like this (likely because the Docker socket is not avialable upon calling docker.from_env):
client = docker.from_env(timeout=DEFAULT_TIMEOUT)
File "/usr/local/lib/python3.6/dist-packages/docker/client.py", line 85, in from_env
timeout=timeout, version=version, **kwargs_from_env(**kwargs)
File "/usr/local/lib/python3.6/dist-packages/docker/client.py", line 40, in __init__
self.api = APIClient(*args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/docker/api/client.py", line 188, in __init__
self._version = self._retrieve_server_version()
File "/usr/local/lib/python3.6/dist-packages/docker/api/client.py", line 213, in _retrieve_server_version
'Error while fetching server API version: {0}'.format(e)
docker.errors.DockerException: Error while fetching server API version: ('Connection aborted.', FileNotFoundError(2, 'No such file or directory'))
Hi @epicfaace! Please set the version as below to avoid querying a Docker engine for your use case:
client = docker.from_env(version="1.35")
If no version is specified as a parameter (auto option), we retrieve the API version from the Docker Engine. This way we avoid breaking clients targeting old engines not implementing the version we had hardcoded before. And we also would not need to update the version anymore as it is automatically retrieved from the engine.
Thanks @aiordache for the workaround. However, this makes 4.3.0 -> 4.3.1 explicitly a backwards incompatible version upgrade; you may want to consider either bumping up the version to 5 or making this change backwards compatible with previous versions.
Most helpful comment
Thanks @aiordache for the workaround. However, this makes 4.3.0 -> 4.3.1 explicitly a backwards incompatible version upgrade; you may want to consider either bumping up the version to 5 or making this change backwards compatible with previous versions.