moto: DockerException in batch model - Error while fetching server API version
This might be a bug somewhere in the python docker package or it might be fixed upstream but moto[server] could use an update to any pinned dependency?
> self.docker_client = docker.from_env()
/opt/conda/envs/project/lib/python3.7/site-packages/moto/batch/models.py:345:
...
self = <docker.api.client.APIClient object at 0x7f8b52ceec90>
def _retrieve_server_version(self):
try:
return self.version(api_version=False)["ApiVersion"]
except KeyError:
raise DockerException(
'Invalid response from docker daemon: key "ApiVersion"'
' is missing.'
)
except Exception as e:
raise DockerException(
> 'Error while fetching server API version: {0}'.format(e)
)
E docker.errors.DockerException: Error while fetching server API version: cannot unpack non-iterable CallbackResponse object
/opt/conda/envs/project/lib/python3.7/site-packages/docker/api/client.py:222: DockerException
versions
$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=18.04
DISTRIB_CODENAME=bionic
DISTRIB_DESCRIPTION="Ubuntu 18.04.5 LTS"
$ docker --version
Docker version 19.03.14, build 5eb3275d40
$ service docker status
● docker.service - Docker Application Container Engine
Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2020-12-03 16:13:07 PST; 1h 26min ago
Docs: https://docs.docker.com
Main PID: 1844 (dockerd)
Tasks: 10
CGroup: /system.slice/docker.service
└─1844 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
$ python --version
Python 3.7.8
$ poetry --version
Poetry version 1.1.4
$ poetry show docker
name : docker
version : 4.4.0
description : A Python library for the Docker Engine API.
dependencies
- pywin32 227
- requests >=2.14.2,<2.18.0 || >2.18.0
- six >=1.4.0
- websocket-client >=0.32.0
$ poetry show moto
name : moto
version : 1.3.16
description : A library that allows your python tests to easily mock out the boto library
dependencies
- aws-xray-sdk >=0.93,<0.96 || >0.96
- boto >=2.36.0
- boto3 >=1.9.201
- botocore >=1.12.201
- cfn-lint >=0.4.0
- cryptography >=2.3.0
- docker >=2.5.1
- ecdsa <0.15
- flask *
- idna >=2.5,<3
- Jinja2 >=2.10.1
- jsondiff >=1.1.2
- MarkupSafe <2.0
- mock *
- more-itertools *
- python-dateutil >=2.1,<3.0.0
- python-jose >=3.1.0,<4.0.0
- pytz *
- PyYAML >=5.1
- requests >=2.5
- responses >=0.9.0
- six >1.9
- werkzeug *
- xmltodict *
- zipp *
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 16 (2 by maintainers)
Thanks for providing the test, @maxwellchandler. Looks like it was only fixed in 1.3.16.dev122 instead. That release contains #3466, a fix for a downstream change in the Responses-library. No idea why that would affect Docker though…
Proof: https://github.com/bblommers/testdockerexception/runs/1688643905?check_suite_focus=true
That repo contains the test you provided, and runs it against various moto-versions. Note that the OSX-test always fails, because Github does not have Docker installed on their OSX machines.