docker / docker-py

A Python library for the Docker Engine API
https://docker-py.readthedocs.io/
Apache License 2.0
6.81k stars 1.67k forks source link

Latest release 5.0.1 container exec_run fails #2885

Closed joelcomp1 closed 3 years ago

joelcomp1 commented 3 years ago

Running urllib3-1.26.6, requests-2.26.0 and latest version of docker 5.0.1 I now can't use the exec_run() cmd any longer to run a script on my container I keep getting:

container.exec_run(f"/opt/jboss/keycloak/bin/add-user-keycloak.sh -u {keycloak_user} -p {keycloak_password}") File "/usr/local/lib/python3.9/site-packages/docker/models/containers.py", line 198, in exec_run exec_output = self.client.api.exec_start( File "/usr/local/lib/python3.9/site-packages/docker/utils/decorators.py", line 19, in wrapped return f(self, resource_id, args, kwargs) File "/usr/local/lib/python3.9/site-packages/docker/api/exec_api.py", line 157, in exec_start res = self._post_json( File "/usr/local/lib/python3.9/site-packages/docker/api/client.py", line 296, in _post_json return self._post(url, data=json.dumps(data2), kwargs) File "/usr/local/lib/python3.9/site-packages/docker/utils/decorators.py", line 46, in inner return f(self, args, kwargs) File "/usr/local/lib/python3.9/site-packages/docker/api/client.py", line 233, in _post return self.post(url, self._set_request_timeout(kwargs)) File "/usr/local/lib/python3.9/site-packages/requests/sessions.py", line 590, in post return self.request('POST', url, data=data, json=json, kwargs) File "/usr/local/lib/python3.9/site-packages/requests/sessions.py", line 542, in request resp = self.send(prep, send_kwargs) File "/usr/local/lib/python3.9/site-packages/requests/sessions.py", line 655, in send r = adapter.send(request, *kwargs) File "/usr/local/lib/python3.9/site-packages/requests/adapters.py", line 439, in send resp = conn.urlopen( File "/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 699, in urlopen httplib_response = self._make_request( File "/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 445, in _make_request six.raise_from(e, None) File "", line 3, in raise_from File "/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 440, in _make_request httplib_response = conn.getresponse() File "/usr/local/lib/python3.9/http/client.py", line 1341, in getresponse response = self.response_class(self.sock, method=self._method) File "/usr/local/lib/python3.9/site-packages/docker/transport/unixconn.py", line 43, in response_class return httplib.HTTPResponse(sock, args, **kwargs) TypeError: init() got an unexpected keyword argument 'disable_buffering'

I resolved by rolling back to 5.0.0 of docker.

Aposhian commented 3 years ago

Same issue here. This appears to be coming from the fact that disable_buffering is being passed to HTTPResponse, when HTTPResponse does not have that argument: https://github.com/docker/docker-py/blob/master/docker/transport/unixconn.py#L41-L43 This was broken on commit https://github.com/docker/docker-py/commit/5fcc293ba268a89ea1535114d36fbdcb73ec3d88 by removing the UnixHTTPResponse class that handled this argument.

shreyapandit commented 3 years ago

Thanks for merging the fix! When should a release be expected for this fix?

teadur commented 3 years ago

Fixed by #2886

felixfontein commented 3 years ago

5.0.2 has been released and contains the fix.

KenwoodFox commented 3 years ago

5.0.2 has been released and contains the fix.

How do you install the new version? Pip reports

Could not find a version that satisfies the requirement docker-py==5.0.2
felixfontein commented 3 years ago

@KenwoodFox the package is called docker for years now. docker-py is the old name which was discontinued in 2016.

KenwoodFox commented 3 years ago

@felixfontein That did it thank you, i was able to install docker==5.0.2 and that worked but i seem to have broken something else

vestabot@raspberrypi:~/silvertech-vestaboard $ docker-compose pull && docker-compose up --force-recreate --build
Pulling core ... done
Recreating board_bot ... done
Attaching to board_bot
board_bot | python: error while loading shared libraries: /lib/arm-linux-gnueabihf/libexpat.so.1: invalid ELF header
board_bot exited with code 0

Im not sure if its a different issue or not though, i did not change anything other than the docker-py version, using the same image to construct my container...

Aposhian commented 3 years ago

@KenwoodFox you may want to open a new issue for that. What version of docker-compose are you using? What version of python are you using?