Skip to content
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

Docker error while fetching server API version #73

Open
Alexander-Degtyar opened this issue Feb 12, 2024 · 3 comments
Open

Docker error while fetching server API version #73

Alexander-Degtyar opened this issue Feb 12, 2024 · 3 comments

Comments

@Alexander-Degtyar
Copy link

Alexander-Degtyar commented Feb 12, 2024

Script failed with the following exception when tried to get compose yaml from the running container.

$ sudo python3 ./autocompose.py <my container id>
Traceback (most recent call last):
  File "/tmp/docker-autocompose/autocompose-venv/lib/python3.8/site-packages/docker/api/client.py", line 214, in _retrieve_server_version
    return self.version(api_version=False)["ApiVersion"]
  File "/tmp/docker-autocompose/autocompose-venv/lib/python3.8/site-packages/docker/api/daemon.py", line 181, in version
    return self._result(self._get(url), json=True)
  File "/tmp/docker-autocompose/autocompose-venv/lib/python3.8/site-packages/docker/utils/decorators.py", line 46, in inner
    return f(self, *args, **kwargs)
  File "/tmp/docker-autocompose/autocompose-venv/lib/python3.8/site-packages/docker/api/client.py", line 237, in _get
    return self.get(url, **self._set_request_timeout(kwargs))
  File "/tmp/docker-autocompose/autocompose-venv/lib/python3.8/site-packages/requests/sessions.py", line 602, in get
    return self.request("GET", url, **kwargs)
  File "/tmp/docker-autocompose/autocompose-venv/lib/python3.8/site-packages/requests/sessions.py", line 589, in request
    resp = self.send(prep, **send_kwargs)
  File "/tmp/docker-autocompose/autocompose-venv/lib/python3.8/site-packages/requests/sessions.py", line 703, in send
    r = adapter.send(request, **kwargs)
  File "/tmp/docker-autocompose/autocompose-venv/lib/python3.8/site-packages/requests/adapters.py", line 486, in send
    resp = conn.urlopen(
  File "/tmp/docker-autocompose/autocompose-venv/lib/python3.8/site-packages/urllib3/connectionpool.py", line 793, in urlopen
    response = self._make_request(
  File "/tmp/docker-autocompose/autocompose-venv/lib/python3.8/site-packages/urllib3/connectionpool.py", line 496, in _make_request
    conn.request(
TypeError: request() got an unexpected keyword argument 'chunked'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "./autocompose.py", line 296, in <module>
    main()
  File "./autocompose.py", line 105, in main
    cfile, c_networks, c_volumes = generate(cname, createvolumes=args.createvolumes)
  File "./autocompose.py", line 144, in generate
    c = docker.from_env()
  File "/tmp/docker-autocompose/autocompose-venv/lib/python3.8/site-packages/docker/client.py", line 96, in from_env
    return cls(
  File "/tmp/docker-autocompose/autocompose-venv/lib/python3.8/site-packages/docker/client.py", line 45, in __init__
    self.api = APIClient(*args, **kwargs)
  File "/tmp/docker-autocompose/autocompose-venv/lib/python3.8/site-packages/docker/api/client.py", line 197, in __init__
    self._version = self._retrieve_server_version()
  File "/tmp/docker-autocompose/autocompose-venv/lib/python3.8/site-packages/docker/api/client.py", line 221, in _retrieve_server_version
    raise DockerException(
docker.errors.DockerException: Error while fetching server API version: request() got an unexpected keyword argument 'chunked'

Docker version:

$ docker --version
Docker version 25.0.2, build 29cf629

$ docker version
Client: Docker Engine - Community
 Version:           25.0.2
 API version:       1.44
 Go version:        go1.21.6
 Git commit:        29cf629
 Built:             Thu Feb  1 00:23:19 2024
 OS/Arch:           linux/amd64
 Context:           default

Server: Docker Engine - Community
 Engine:
  Version:          25.0.2
  API version:      1.44 (minimum version 1.24)
  Go version:       go1.21.6
  Git commit:       fce6e0c
  Built:            Thu Feb  1 00:23:19 2024
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.6.28
  GitCommit:        ae07eda36dd25f8a1b98dfbf587313b99c0190bb
 runc:
  Version:          1.1.12
  GitCommit:        v1.1.12-0-g51d5e94
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

Packages versions:

$ pip3 freeze
certifi==2024.2.2
charset-normalizer==3.3.2
docker==4.4.4
idna==3.6
pyaml==20.4.0
PyYAML==6.0.1
requests==2.31.0
six==1.16.0
urllib3==2.2.0
websocket-client==1.7.0

Script version:

$ git log -1
commit 2e6a55fad651941d33084d2d37793efc270780da (HEAD -> master, origin/master, origin/HEAD)
Author: Bitals <[email protected]>
Date:   Tue Nov 28 02:08:31 2023 +0000

    Installation instructions and AUR (#68)
    
    I added a bit of information about installing this tool to the system and about my AUR packages.
    
    Also the PyPI version is outdated (1.0.1 from Jan 3 2016, https://pypi.org/project/docker-autocompose/#history), is it still supported?

Probably related to the #60.

@Alexander-Degtyar
Copy link
Author

After installing older requests, the script works fine.

$ pip3 install "requests<2.2.29"
Collecting requests<2.2.29
  Downloading requests-2.2.1-py2.py3-none-any.whl (625 kB)
     |████████████████████████████████| 625 kB 2.2 MB/s 
ERROR: docker 4.4.4 has requirement requests!=2.18.0,>=2.14.2, but you'll have requests 2.2.1 which is incompatible.
Installing collected packages: requests
  Attempting uninstall: requests
    Found existing installation: requests 2.31.0
    Uninstalling requests-2.31.0:
      Successfully uninstalled requests-2.31.0
Successfully installed requests-2.2.1

@ticapix
Copy link

ticapix commented May 9, 2024

Hi,

In my case, downgrading requests was introducing a dependency error with the docker package.

Another workaround found docker/docker-py#3113 (comment) is to force urllib3 version below v2

pip3 install "urllib3<2"

@fryfrog
Copy link

fryfrog commented Dec 30, 2024

We're seeing this when running the docker image as well, like...

sudo docker run --rm -v /ver/run/docker.sock:/var/run/docker.sock ghcr.io/red5d/docker-autocompose

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants