-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
error while using docker for mac client 2.5.0.0 #2696
Comments
Hello, same/similar issue. Python version: 3.8.6 reproducer: import docker
client = docker.from_env()
client.containers.get("<non-existent-container-name>") expected result: result: Traceback (most recent call last):
File "/Users/mconcas/.virtualenvs/alidock/lib/python3.8/site-packages/urllib3/response.py", line 696, in _update_chunk_length
self.chunk_left = int(line, 16)
ValueError: invalid literal for int() with base 16: b''
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/mconcas/.virtualenvs/alidock/lib/python3.8/site-packages/urllib3/response.py", line 436, in _error_catcher
yield
File "/Users/mconcas/.virtualenvs/alidock/lib/python3.8/site-packages/urllib3/response.py", line 763, in read_chunked
self._update_chunk_length()
File "/Users/mconcas/.virtualenvs/alidock/lib/python3.8/site-packages/urllib3/response.py", line 700, in _update_chunk_length
raise httplib.IncompleteRead(line)
http.client.IncompleteRead: IncompleteRead(0 bytes read)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/mconcas/.virtualenvs/alidock/lib/python3.8/site-packages/requests/models.py", line 751, in generate
for chunk in self.raw.stream(chunk_size, decode_content=True):
File "/Users/mconcas/.virtualenvs/alidock/lib/python3.8/site-packages/urllib3/response.py", line 571, in stream
for line in self.read_chunked(amt, decode_content=decode_content):
File "/Users/mconcas/.virtualenvs/alidock/lib/python3.8/site-packages/urllib3/response.py", line 792, in read_chunked
self._original_response.close()
File "/usr/local/Cellar/[email protected]/3.8.6/Frameworks/Python.framework/Versions/3.8/lib/python3.8/contextlib.py", line 131, in __exit__
self.gen.throw(type, value, traceback)
File "/Users/mconcas/.virtualenvs/alidock/lib/python3.8/site-packages/urllib3/response.py", line 454, in _error_catcher
raise ProtocolError("Connection broken: %r" % e, e)
urllib3.exceptions.ProtocolError: ('Connection broken: IncompleteRead(0 bytes read)', IncompleteRead(0 bytes read))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "reproducer.py", line 5, in <module>
client.containers.get("asdrubale")
File "/Users/mconcas/.virtualenvs/alidock/lib/python3.8/site-packages/docker/models/containers.py", line 887, in get
resp = self.client.api.inspect_container(container_id)
File "/Users/mconcas/.virtualenvs/alidock/lib/python3.8/site-packages/docker/utils/decorators.py", line 19, in wrapped
return f(self, resource_id, *args, **kwargs)
File "/Users/mconcas/.virtualenvs/alidock/lib/python3.8/site-packages/docker/api/container.py", line 771, in inspect_container
self._get(self._url("/containers/{0}/json", container)), True
File "/Users/mconcas/.virtualenvs/alidock/lib/python3.8/site-packages/docker/utils/decorators.py", line 46, in inner
return f(self, *args, **kwargs)
File "/Users/mconcas/.virtualenvs/alidock/lib/python3.8/site-packages/docker/api/client.py", line 228, in _get
return self.get(url, **self._set_request_timeout(kwargs))
File "/Users/mconcas/.virtualenvs/alidock/lib/python3.8/site-packages/requests/sessions.py", line 543, in get
return self.request('GET', url, **kwargs)
File "/Users/mconcas/.virtualenvs/alidock/lib/python3.8/site-packages/requests/sessions.py", line 530, in request
resp = self.send(prep, **send_kwargs)
File "/Users/mconcas/.virtualenvs/alidock/lib/python3.8/site-packages/requests/sessions.py", line 685, in send
r.content
File "/Users/mconcas/.virtualenvs/alidock/lib/python3.8/site-packages/requests/models.py", line 829, in content
self._content = b''.join(self.iter_content(CONTENT_CHUNK_SIZE)) or b''
File "/Users/mconcas/.virtualenvs/alidock/lib/python3.8/site-packages/requests/models.py", line 754, in generate
raise ChunkedEncodingError(e)
requests.exceptions.ChunkedEncodingError: ('Connection broken: IncompleteRead(0 bytes read)', IncompleteRead(0 bytes read))``` |
An interesting observation on various version. I'm seeing this same issue on:
I do not see this issue on:
|
We use this pattern to check if a container exists already before starting a container or when fetching the status of a container, as our software uses deterministic container names. In the case where the container isn't running we catch A very temporary fix is catching the unexpected error, again this is unexpected, fragile, and possibly not useful for everyone's use case:
|
I have the same exact problem, and I implemented the same fix. I just came here to open an issue. :) Python 3.7.9 / docker-py 4.3.1 / Docker: |
Mac facing the same problem :) hope it gets resolved! thanks guys |
Also on Linux:
Python 3.6.8 (default, Apr 2 2020, 13:34:55)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import docker
>>> client = docker.from_env()
>>> client.containers.get("<non-existent-container-name>")
Traceback (most recent call last):
File "/home/mconcas/.virtualenvs/alidock/lib64/python3.6/site-packages/docker/api/client.py", line 259, in _raise_for_status
response.raise_for_status()
File "/home/mconcas/.virtualenvs/alidock/lib64/python3.6/site-packages/requests/models.py", line 941, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: http+docker://localhost/v1.40/containers/%3Cnon-existent-container-name%3E/json
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/mconcas/.virtualenvs/alidock/lib64/python3.6/site-packages/docker/models/containers.py", line 887, in get
resp = self.client.api.inspect_container(container_id)
File "/home/mconcas/.virtualenvs/alidock/lib64/python3.6/site-packages/docker/utils/decorators.py", line 19, in wrapped
return f(self, resource_id, *args, **kwargs)
File "/home/mconcas/.virtualenvs/alidock/lib64/python3.6/site-packages/docker/api/container.py", line 771, in inspect_container
self._get(self._url("/containers/{0}/json", container)), True
File "/home/mconcas/.virtualenvs/alidock/lib64/python3.6/site-packages/docker/api/client.py", line 265, in _result
self._raise_for_status(response)
File "/home/mconcas/.virtualenvs/alidock/lib64/python3.6/site-packages/docker/api/client.py", line 261, in _raise_for_status
raise create_api_error_from_http_exception(e)
File "/home/mconcas/.virtualenvs/alidock/lib64/python3.6/site-packages/docker/errors.py", line 31, in create_api_error_from_http_exception
raise cls(e, response=response, explanation=explanation)
docker.errors.NotFound: 404 Client Error: Not Found ("No such container: <non-existent-container-name>") |
Same issue - I was able to downgrade to 2.4 (link) to get it working again, no factory reset necessary. |
They have just released version 2.5.0.1 which states to have fixed another Mac related issue (as you can see here in their docs). Not sure whether that also fixes this issue (which I sadly cannot test as I do not have a Mac), but I figured it was worth mentioning. |
Docker 2.5.0.1 does not fix this issue on the mac. I upgraded to 2.5.0.1 and tested it. 2.5.0.1 fixes an issue with Big Sur and Virtualbox. |
Will test it soon. Somehow new docker-desktop downgraded kubernetes to 1.16.6-beta.0 from 1.19.3 (by using kubectl get nodes), but that's not related to this issue. |
This issue is affecting our container builds, I don't know if there's a release coming out soon to fix this. |
As a side note: the CI does not catch the problem because the default docker version in Travis is still 18.x ... |
fixes docker/docker-py#2696 by catching exceptions.
fixes docker/docker-py#2696 by catching exceptions.
I think this may be the same issue as docker/for-mac#5025 / docker/for-mac#5058 / docker/for-mac#5059. More details can be found in this comment: docker/for-mac#5059 (comment) |
If the python code you're running is running on the mac itself, I'm not sure if there's a workaround, but if the code is running inside a container, you can (as a workaround) bind-mount |
Oh, actually, there might be a workaround; the "raw" socket is also available on the mac side in; $ ls -la ~/Library/Containers/com.docker.docker/Data/docker.raw.sock
srwxr-xr-x 1 sebastiaan staff 0 Nov 16 11:24 docker.raw.sock= e.g.; $ docker -H unix:///Users/sebastiaan/Library/Containers/com.docker.docker/Data/docker.raw.sock version
Client: Docker Engine - Community
Version: 20.10.0-beta1
API version: 1.41
Go version: go1.13.15
Git commit: ac365d7
Built: Tue Oct 13 18:13:53 2020
OS/Arch: darwin/amd64
Context: default
Experimental: true
...
☝️ ☝️ ☝️ ☝️ IOW: the recommended socket to use will be |
Yes, I believe that it the exact cause of this issue. docker/for-mac#5025 |
looks like the issue should be fixed in the latest edge release that was just published docker/for-mac#5025 (comment) |
Latest edge doesn't fix this for me. Can someone confirm? |
Error from trying to find a non-existent container (test suite log):
|
Can confirm that I still see the problem; Incorrect response with the proxied socket; $ curl -v --unix-socket /var/run/docker.sock http://localhost/containers/nosuchcontainer/json
* Trying /var/run/docker.sock:0...
* Connected to localhost (docker.sock) port 80 (#0)
> GET /containers/nosuchcontainer/json HTTP/1.1
> Host: localhost
> User-Agent: curl/7.65.3
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 404 Not Found
< Api-Version: 1.41
< Content-Type: application/json
< Date: Fri, 20 Nov 2020 14:23:21 GMT
< Docker-Experimental: true
< Ostype: linux
< Server: Docker/20.10.0-rc1 (linux)
< Transfer-Encoding: chunked
<
* transfer closed with outstanding read data remaining
* Closing connection 0
curl: (18) transfer closed with outstanding read data remaining Works correct with the 'raw' socket: $ curl -v --unix-socket ~/Library/Containers/com.docker.docker/Data/docker.raw.sock http://localhost/containers/nosuchcontainer/json
* Trying /Users/sebastiaan/Library/Containers/com.dock:0...
* Connected to localhost (/Users/sebastiaan/Library/Containers/com.dock) port 80 (#0)
> GET /containers/nosuchcontainer/json HTTP/1.1
> Host: localhost
> User-Agent: curl/7.65.3
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 404 Not Found
< Api-Version: 1.41
< Content-Type: application/json
< Docker-Experimental: true
< Ostype: linux
< Server: Docker/20.10.0-rc1 (linux)
< Date: Fri, 20 Nov 2020 14:22:40 GMT
< Content-Length: 49
<
{"message":"No such container: nosuchcontainer"}
* Connection #0 to host localhost left intact |
This should be fixed in docker desktop 2.5.2 and up; curl -v --unix-socket /var/run/docker.sock http://localhost/containers/nosuchcontainer/json
* Trying /var/run/docker.sock:0...
* Connected to localhost (docker.sock) port 80 (#0)
> GET /containers/nosuchcontainer/json HTTP/1.1
> Host: localhost
> User-Agent: curl/7.65.3
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 404 Not Found
< Api-Version: 1.41
< Content-Type: application/json
< Date: Tue, 01 Dec 2020 16:22:01 GMT
< Docker-Experimental: true
< Ostype: linux
< Server: Docker/20.10.0-rc1 (linux)
< Transfer-Encoding: chunked
<
{"message":"No such container: nosuchcontainer"}
* Connection #0 to host localhost left intact |
@thaJeztah I'm trying to migrate from 2.3.2 to higher, we are uing docker stack like:
Is there a way not to add ".raw", cause it is not backward compatible and will fail for those who stay on 2.3.2 (we have way to many non programmer users who will not know what to do with this) |
This is fixed in current versions of Docker Desktop. |
Initially created in #22250 Both original issues are already solved for over 2.5 years: - docker/for-mac#5025 - docker/docker-py#2696 This will also allow anyone to use Orbstack without any modifications.
Using python 3.8.5 and docker-py version 4.3.1
The text was updated successfully, but these errors were encountered: