AttributeError: 'generator' object has no attribute 'read' with new python docker client version 3.0
See original GitHub issueHello
We use docker-squash on a daily basis to squash our base-images. Today we can’t squash the images anymore. We get:
$ docker-squash -t registry.example.com/alpine registry.exmaple.com/alpine
2018-02-01 06:24:59,601 root INFO docker-squash version 1.0.6, Docker c97c6d6, API 1.35...
2018-02-01 06:24:59,602 root INFO Using v2 image format
2018-02-01 06:24:59,614 root INFO Old image has 4 layers
2018-02-01 06:24:59,615 root INFO Checking if squashing is necessary...
2018-02-01 06:24:59,615 root INFO Attempting to squash last 4 layers...
2018-02-01 06:24:59,615 root INFO Saving image sha256:370c6891b7c58c64a715aaf93f17e1e10c8a4e4e3533e04a0959f1f205756cbe to /tmp/docker-squash-ujuyJb/old directory...
2018-02-01 06:25:00,849 root ERROR 'generator' object has no attribute 'read'
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/docker_squash/image.py", line 321, in _save_image
with tarfile.open(fileobj=image, mode='r|') as tar:
File "/usr/lib/python2.7/tarfile.py", line 1705, in open
t = cls(name, filemode, stream, **kwargs)
File "/usr/lib/python2.7/tarfile.py", line 1587, in __init__
self.firstmember = self.next()
File "/usr/lib/python2.7/tarfile.py", line 2358, in next
tarinfo = self.tarinfo.fromtarfile(self)
File "/usr/lib/python2.7/tarfile.py", line 1251, in fromtarfile
buf = tarfile.fileobj.read(BLOCKSIZE)
File "/usr/lib/python2.7/tarfile.py", line 579, in read
buf = self._read(size)
File "/usr/lib/python2.7/tarfile.py", line 587, in _read
return self.__read(size)
File "/usr/lib/python2.7/tarfile.py", line 612, in __read
buf = self.fileobj.read(self.bufsize)
AttributeError: 'generator' object has no attribute 'read'
Docker-squash was installed on our builder Image (docker:latest) by pip:
$ pip install docker-squash
Collecting docker-squash
Downloading docker-squash-1.0.6.tar.gz
Collecting docker (from docker-squash)
Downloading docker-3.0.0-py2.py3-none-any.whl (120kB)
Collecting six (from docker-squash)
Downloading six-1.11.0-py2.py3-none-any.whl
Collecting backports.ssl-match-hostname>=3.5; python_version < "3.5" (from docker->docker-squash)
Downloading backports.ssl_match_hostname-3.5.0.1.tar.gz
Collecting ipaddress>=1.0.16; python_version < "3.3" (from docker->docker-squash)
Downloading ipaddress-1.0.19.tar.gz
Collecting docker-pycreds>=0.2.1 (from docker->docker-squash)
Downloading docker_pycreds-0.2.1-py2.py3-none-any.whl
Collecting requests!=2.18.0,>=2.14.2 (from docker->docker-squash)
Downloading requests-2.18.4-py2.py3-none-any.whl (88kB)
Collecting websocket-client>=0.32.0 (from docker->docker-squash)
Downloading websocket_client-0.46.0-py2.py3-none-any.whl (200kB)
Collecting chardet<3.1.0,>=3.0.2 (from requests!=2.18.0,>=2.14.2->docker->docker-squash)
Downloading chardet-3.0.4-py2.py3-none-any.whl (133kB)
Collecting certifi>=2017.4.17 (from requests!=2.18.0,>=2.14.2->docker->docker-squash)
Downloading certifi-2018.1.18-py2.py3-none-any.whl (151kB)
Collecting urllib3<1.23,>=1.21.1 (from requests!=2.18.0,>=2.14.2->docker->docker-squash)
Downloading urllib3-1.22-py2.py3-none-any.whl (132kB)
Collecting idna<2.7,>=2.5 (from requests!=2.18.0,>=2.14.2->docker->docker-squash)
Downloading idna-2.6-py2.py3-none-any.whl (56kB)
Installing collected packages: backports.ssl-match-hostname, ipaddress, six, docker-pycreds, chardet, certifi, urllib3, idna, requests, websocket-client, docker, docker-squash
Running setup.py install for backports.ssl-match-hostname: started
Running setup.py install for backports.ssl-match-hostname: finished with status 'done'
Running setup.py install for ipaddress: started
Running setup.py install for ipaddress: finished with status 'done'
Running setup.py install for docker-squash: started
Running setup.py install for docker-squash: finished with status 'done'
Successfully installed backports.ssl-match-hostname-3.5.0.1 certifi-2018.1.18 chardet-3.0.4 docker-3.0.0 docker-pycreds-0.2.1 docker-squash-1.0.6 idna-2.6 ipaddress-1.0.19 requests-2.18.4 six-1.11.0 urllib3-1.22 websocket-client-0.46.0
The only thing that changed from yesterday is the docker python client we are using:
Collecting docker (from docker-squash)
Downloading docker-3.0.0-py2.py3-none-any.whl (120kB)
Yesterday it worked, but we were using docker-2.7.0.
Can you look into this?
Thanks
Issue Analytics
- State:
- Created 6 years ago
- Reactions:20
- Comments:14 (7 by maintainers)
Top Results From Across the Web
Moto sns client can't call create_topic AttributeError
OK, I'm not 100% sure why but adding the sts decorator seems to have fixed this: @mock_sts def test_publish(sns): resp ...
Read more >Low-level API — Docker SDK for Python 6.0.1 documentation
APIClient(base_url='unix://var/run/docker.sock') >>> client.version() ... /dev/sda:/dev/xvda:rwm allows the container to have read-write access to the ...
Read more >attributeerror: 'generator' object has no attribute 'query'
Looking at your code, it looks like you're trying use Python as a DBMS, which it is not. You do not need to...
Read more >Python Client API Reference — MinIO Object Storage for Linux
The solution is simply to create a new Minio object in each process, and not share it between processes. Example. from minio import...
Read more >docker-sdk-python Documentation - Read the Docs
To communicate with the Docker daemon, you first need to instantiate a client. The easiest way to do that is by calling.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Oh crap, I totally forgot 😦 I’ll work on this this week!
1.0.7released, sorry for the delay! https://github.com/goldmann/docker-squash/releases/tag/1.0.7