** Summary changed:

- python3-docker `from_env()` broken
+ [SRU] python3-docker `from_env()` broken

** Description changed:

- I have a python script that manages some docker resources. It uses the
- `from_env()` method to build the client. This script always runs as
- root.
+ [ Impact ]
  
- This worked in Ubuntu 22.04. However, it seems like something is
- mismatched in 24.04, as I now get the following error, even after a
- reboot (which seemed to solve this for others in the past?). It appears
- based on cursory googling that a library version might be out of sync.
+ python3-docker is completely unusable. It will fail immediately when the
+ user tries to use it after importing the module.
  
- ```
  Traceback (most recent call last):
-   File "/usr/bin/oqm-captain", line 62, in <module>
-     ContainerUtils.ensureSharedDockerResources()
-   File "/usr/lib/oqm/station-captain/ContainerUtils.py", line 55, in 
ensureSharedDockerResources
-     client = docker.from_env()
-              ^^^^^^^^^^^^^^^^^
+   File "<stdin>", line 1, in <module>
    File "/usr/lib/python3/dist-packages/docker/client.py", line 96, in from_env
      return cls(
             ^^^^
    File "/usr/lib/python3/dist-packages/docker/client.py", line 45, in __init__
      self.api = APIClient(*args, **kwargs)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/usr/lib/python3/dist-packages/docker/api/client.py", line 197, in 
__init__
      self._version = self._retrieve_server_version()
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/usr/lib/python3/dist-packages/docker/api/client.py", line 221, in 
_retrieve_server_version
      raise DockerException(
  docker.errors.DockerException: Error while fetching server API version: 
HTTPConnection.request() got an unexpected keyword argument 'chunked'
+ 
+ 
+ [ Test Plan ]
+ 
+ Install python3-docker and docker.io
+ In the python3 prompt, use the following commands to test:
+ 
+ >>> import docker
+ >>> client = docker.from_env()
+ >>> client.containers.run("ubuntu:latest", "echo hello world")
+ 
+ With the fixed package it will print:
+ b'hello world\n'
+ 
+ Note: the test expects the user is part of docker group. If not, then
+ use "sudo python3" to get to the python prompt.
+ 
+ [ Where problems could occur ]
+ 
+ The upstream patch is using urllib3 and is changing the way it makes the
+ network connections. The testplan is only testing one usecase. So there
+ might be a chance that other types of connections are not working after
+ this change. But considering the fact the python3-docker is unusable
+ now, the user should not see any new regression than what already
+ exists.
+ 
+ 
+ [ Other Info ]
+ 
+ 1. This has been fixed in Debian and so Oracular is also fixed.
+ 2. A new runtime dependency on python3-urllib3 has been added as is done in 
Debian.
+ 
+ 
+ [ Original Bug Description ]
+ 
+ 
+ I have a python script that manages some docker resources. It uses the 
`from_env()` method to build the client. This script always runs as root.
+ 
+ This worked in Ubuntu 22.04. However, it seems like something is
+ mismatched in 24.04, as I now get the following error, even after a
+ reboot (which seemed to solve this for others in the past?). It appears
+ based on cursory googling that a library version might be out of sync.
+ 
+ ```
+ Traceback (most recent call last):
+   File "/usr/bin/oqm-captain", line 62, in <module>
+     ContainerUtils.ensureSharedDockerResources()
+   File "/usr/lib/oqm/station-captain/ContainerUtils.py", line 55, in 
ensureSharedDockerResources
+     client = docker.from_env()
+              ^^^^^^^^^^^^^^^^^
+   File "/usr/lib/python3/dist-packages/docker/client.py", line 96, in from_env
+     return cls(
+            ^^^^
+   File "/usr/lib/python3/dist-packages/docker/client.py", line 45, in __init__
+     self.api = APIClient(*args, **kwargs)
+                ^^^^^^^^^^^^^^^^^^^^^^^^^^
+   File "/usr/lib/python3/dist-packages/docker/api/client.py", line 197, in 
__init__
+     self._version = self._retrieve_server_version()
+                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   File "/usr/lib/python3/dist-packages/docker/api/client.py", line 221, in 
_retrieve_server_version
+     raise DockerException(
+ docker.errors.DockerException: Error while fetching server API version: 
HTTPConnection.request() got an unexpected keyword argument 'chunked'
  ```
  
  This is on a fresh 24.04 install.
  
  Willing to help diagnose, but to replicate:
  
-  1. `apt install docker.io python3-docker`
-  2. `python3`
-  3. `import docker`
-  4. `docker.from_env()`
+  1. `apt install docker.io python3-docker`
+  2. `python3`
+  3. `import docker`
+  4. `docker.from_env()`

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2065348

Title:
  [SRU] python3-docker `from_env()` broken

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/python-docker/+bug/2065348/+subscriptions


-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to