I'm using docker-py for my project, and find out that cli.get_image() method will raise an exception if the image loading exceeds 60s. Following is the traceback:
File "/usr/lib/python2.7/site-packages/docker/utils/decorators.py", line 21, in wrapped
return f(self, resource_id, *args, **kwargs)
File "/usr/lib/python2.7/site-packages/docker/api/image.py", line 17, in get_image
res = self._get(self._url("/images/{0}/get", image), stream=True)
File "/usr/lib/python2.7/site-packages/docker/utils/decorators.py", line 47, in inner
return f(self, *args, **kwargs)
File "/usr/lib/python2.7/site-packages/docker/client.py", line 112, in _get
return self.get(url, **self._set_request_timeout(kwargs))
File "/usr/lib/python2.7/site-packages/requests/sessions.py", line 476, in get
return self.request('GET', url, **kwargs)
File "/usr/lib/python2.7/site-packages/requests/sessions.py", line 464, in request
resp = self.send(prep, **send_kwargs)
File "/usr/lib/python2.7/site-packages/requests/sessions.py", line 576, in send
r = adapter.send(request, **kwargs)
File "/usr/lib/python2.7/site-packages/requests/adapters.py", line 433, in send
raise ReadTimeout(e, request=request)
requests.exceptions.ReadTimeout: UnixHTTPConnectionPool(host='localhost', port=None): Read timed out. (read timeout=60)
This works fine if the image is small and whole process can finish within 60s.
I don't know if this is a docker-py issue or docker api issue, but the feature I want is: get_image will return immediately, and I can stream the data later instead of waiting for all data is returned in one response(think about Large Image Size and Poor Network).
Here is the information:
docker-py==1.7.2
Python 2.7.10
# docker version
Client:
Version: 1.9.1
API version: 1.21
Package version: docker-1.9.1-25.el7.centos.x86_64
Go version: go1.4.2
Git commit: 78ee77d/1.9.1
Built:
OS/Arch: linux/amd64
Server:
Version: 1.9.1
API version: 1.21
Package version: docker-1.9.1-25.el7.centos.x86_64
Go version: go1.4.2
Git commit: 78ee77d/1.9.1
Built:
OS/Arch: linux/amd64
You're going to have to increase the HTTP timeout parameter. c = docker.Client(..., timeout=300)
I'm having a similar issue pushing images when using a remote docker api HTTPConnectionPool(host='*.*.*.*', port=4243): Read timed out.(host redacted)
It's almost as if the timeout is timing out if the push takes longer than the set timeout.
Most helpful comment
You're going to have to increase the HTTP timeout parameter.
c = docker.Client(..., timeout=300)