question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

error while using docker for mac client 2.5.0.0

See original GitHub issue

Using python 3.8.5 and docker-py version 4.3.1

  File "/Users/mmoskwa/.local/share/virtualenvs/lunchbox-5JMc0Mx2/lib/python3.8/site-packages/docker/models/containers.py", line 887, in get
    resp = self.client.api.inspect_container(container_id)
  File "/Users/mmoskwa/.local/share/virtualenvs/lunchbox-5JMc0Mx2/lib/python3.8/site-packages/docker/utils/decorators.py", line 19, in wrapped
    return f(self, resource_id, *args, **kwargs)
  File "/Users/mmoskwa/.local/share/virtualenvs/lunchbox-5JMc0Mx2/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/mmoskwa/.local/share/virtualenvs/lunchbox-5JMc0Mx2/lib/python3.8/site-packages/docker/utils/decorators.py", line 46, in inner
    return f(self, *args, **kwargs)
  File "/Users/mmoskwa/.local/share/virtualenvs/lunchbox-5JMc0Mx2/lib/python3.8/site-packages/docker/api/client.py", line 228, in _get
    return self.get(url, **self._set_request_timeout(kwargs))
  File "/Users/mmoskwa/.local/share/virtualenvs/lunchbox-5JMc0Mx2/lib/python3.8/site-packages/requests/sessions.py", line 543, in get
    return self.request('GET', url, **kwargs)
  File "/Users/mmoskwa/.local/share/virtualenvs/lunchbox-5JMc0Mx2/lib/python3.8/site-packages/requests/sessions.py", line 530, in request
    resp = self.send(prep, **send_kwargs)
  File "/Users/mmoskwa/.local/share/virtualenvs/lunchbox-5JMc0Mx2/lib/python3.8/site-packages/requests/sessions.py", line 685, in send
    r.content
  File "/Users/mmoskwa/.local/share/virtualenvs/lunchbox-5JMc0Mx2/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/mmoskwa/.local/share/virtualenvs/lunchbox-5JMc0Mx2/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))

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:24
  • Comments:25 (7 by maintainers)

github_iconTop GitHub Comments

5reactions
mconcascommented, Nov 3, 2020

Hello, same/similar issue.

Python version: 3.8.6 Docker version: 2.5.0 docker-py version: 4.3.1 urllib3 version: 1.25.11

reproducer:

import docker

client = docker.from_env()
client.containers.get("<non-existent-container-name>")

expected result: Exception at docker api level (docker.errors.NotFound or docker.errors.APIError)

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/python@3.8/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))```
3reactions
dkleissacommented, Nov 3, 2020

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 docker.errors.NotFound, which is now broken as @mconcas points out. After initial testing, it does appear this is the only place in the API that is broken like this.

A very temporary fix is catching the unexpected error, again this is unexpected, fragile, and possibly not useful for everyone’s use case:

import docker

client = docker.from_env()
try:
    client.containers.get("<non-existent-container-name>")
except docker.errors.NotFound:
    pass
except requests.exceptions.ChunkedEncodingError:
    pass
Read more comments on GitHub >

github_iconTop Results From Across the Web

Docker won't run on Big Sur | Apple Developer Forums
Docker won't start on Big Sur. Has anyone else tried it? I'll re-install to see if that helps, but Docker doesn't start right...
Read more >
Docker Desktop for Mac 2.x release notes
Fixed an issue that caused Docker Desktop to crash on MacOS 11.0 (Big Sur) when VirtualBox was ... Docker Desktop 2.5.0.0 contains a...
Read more >
Docker Desktop release notes
Fixed an issue preventing the creation of Dev Environments on new Mac installs and causing error "Cannot connect to the Docker daemon at...
Read more >
Docker Desktop for Mac 3.x release notes
Fixed error showing stderr log in the UI. Fixes docker/for-mac#5688. Fixed an issue which caused riscv64 emulation to fail on Docker Desktop.
Read more >
Overview | Docker Documentation
In the Console app . Mac provides a built-in log viewer, named Console, which you can use to check Docker logs. The Console...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found