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.errors.DockerException: Error while fetching server API version: HTTPConnection.request() got an unexpected keyword argument 'chunked' #2578

Closed
slyfox1186 opened this issue Jan 6, 2024 · 14 comments
Labels
reason/external Closed because issue is caused by external factors

Comments

@slyfox1186
Copy link

Describe the problem

This just started out of nowhere and now I can get my server up. I removed the docker image that was running the server using docker stop $ID; docker rm $ID. Then I tried moving the directory to what is listed in the docker-compose file I have added to this request. And I get this error. It use to work fine a few days ago.

Everyone is pissed at me.

Can you take a second to give me a little advice?

Container definition

version: '3.8'

services:
  mc-forge:
    image: itzg/minecraft-server:java17
    environment:
      ANNOUNCE_PLAYER_ACHIEVEMENTS: "false"
      DIFFICULTY: "normal"
      ENABLE_QUERY: "true"
      EULA: "true"
      CF_SERVER_MOD: "https://mediafilez.forgecdn.net/files/4985/960/Server-Files-0.2.34.zip"
      DIFFICULTY: "normal"
      ENABLE_QUERY: "true"
      ENABLE_RCON: "false"
      MAX_TICK_TIME: 60000
      MEMORY: 12G
      MAX_PLAYERS: 50
      MOTD: "Jeffy Boy's Minecraft Server\nNo griefing, stealing, destroying, or killing other players. You will be banned!"
      PVP: "true"
      TYPE: CURSEFORGE
      REMOVE_OLD_MODS: "true"
      SERVER_NAME: "GET REKT"
      VIEW_DISTANCE: 15
    tty: true
    stdin_open: true
    restart: always
    ports:
      - 25565:25565
    volumes:
      - ./Servers/minecraft-forge:/data
      - ./Servers/minecraft-forge/modpacks:/modpacks:ro

Container logs

jman@JSERVERPC$sudo docker-compose up -d
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/docker/api/client.py", line 214, in _retrieve_server_version
    return self.version(api_version=False)["ApiVersion"]
  File "/usr/lib/python3/dist-packages/docker/api/daemon.py", line 181, in version
    return self._result(self._get(url), json=True)
  File "/usr/lib/python3/dist-packages/docker/utils/decorators.py", line 46, in inner
    return f(self, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/docker/api/client.py", line 237, in _get
    return self.get(url, **self._set_request_timeout(kwargs))
  File "/usr/local/lib/python3.10/dist-packages/requests-2.31.0-py3.10.egg/requests/sessions.py", line 602, in get
    return self.request("GET", url, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/requests-2.31.0-py3.10.egg/requests/sessions.py", line 589, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python3.10/dist-packages/requests-2.31.0-py3.10.egg/requests/sessions.py", line 703, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/requests-2.31.0-py3.10.egg/requests/adapters.py", line 485, in send
    resp = conn.urlopen(
  File "/usr/local/lib/python3.10/dist-packages/urllib3-2.1.0-py3.10.egg/urllib3/connectionpool.py", line 790, in urlopen
    response = self._make_request(
  File "/usr/local/lib/python3.10/dist-packages/urllib3-2.1.0-py3.10.egg/urllib3/connectionpool.py", line 496, in _make_request
    conn.request(
TypeError: HTTPConnection.request() got an unexpected keyword argument 'chunked'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/bin/docker-compose", line 33, in <module>
    sys.exit(load_entry_point('docker-compose==1.29.2', 'console_scripts', 'docker-compose')())
  File "/usr/lib/python3/dist-packages/compose/cli/main.py", line 81, in main
    command_func()
  File "/usr/lib/python3/dist-packages/compose/cli/main.py", line 200, in perform_command
    project = project_from_options('.', options)
  File "/usr/lib/python3/dist-packages/compose/cli/command.py", line 60, in project_from_options
    return get_project(
  File "/usr/lib/python3/dist-packages/compose/cli/command.py", line 152, in get_project
    client = get_client(
  File "/usr/lib/python3/dist-packages/compose/cli/docker_client.py", line 41, in get_client
    client = docker_client(
  File "/usr/lib/python3/dist-packages/compose/cli/docker_client.py", line 170, in docker_client
    client = APIClient(use_ssh_client=not use_paramiko_ssh, **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'
@slyfox1186
Copy link
Author

slyfox1186 commented Jan 6, 2024

Running a shell script fixed it. Must be docker-compose related.

#!/usr/bin/env bash

clear

motd="Jeffy Boy's Minecraft Server\nNo griefing, stealing, destroying, or killing other players. You will be banned!"
url='https://mediafilez.forgecdn.net/files/4985/960/Server-Files-0.2.34.zip'

sudo docker run -d \
                -it \
                -e ANNOUNCE_PLAYER_ACHIEVEMENTS="false" \
                -e DIFFICULTY="normal" \
                -e ENABLE_QUERY="true" \
                -e EULA="true" \
                -e CF_SERVER_MOD="$url" \
                -e DIFFICULTY="normal" \
                -e ENABLE_QUERY="true" \
                -e ENABLE_RCON="false" \
                -e MAX_TICK_TIME="60000" \
                -e MEMORY="12G" \
                -e MAX_PLAYERS="50" \
                -e MOTD="$motd" \
                -e PVP="true" \
                -e TYPE="CURSEFORGE" \
                -e REMOVE_OLD_MODS="true" \
                -e SERVER_NAME="GET REKT" \
                -e VIEW_DISTANCE="15" \
                -e restart="always" \
                -p "25565:25565" \
                -v "$PWD/Servers/minecraft-forge:/data" \
                -v "$PWD/Servers/minecraft-forge/modpacks:/modpacks:ro" \
                --name "mc-forge" \
                itzg/minecraft-server:java17

@itzg
Copy link
Owner

itzg commented Jan 6, 2024

You seem to be using an ancient version of docker-compose. Since you're getting a python stack dump this is a) nothing related to my image b) indicates you're using the he old python based tool. Upgrade your docker tooling and you'll find that docker compose is now a native command.

@itzg itzg added reason/external Closed because issue is caused by external factors and removed bug status/needs triage labels Jan 6, 2024
@itzg itzg closed this as not planned Won't fix, can't repro, duplicate, stale Jan 6, 2024
@slyfox1186
Copy link
Author

slyfox1186 commented Jan 6, 2024

Thanks. I changed the code from docker-compose to docker compose and it works.

@helio2323
Copy link

@slyfox1186

thanks my friend, this comand work with me docker compose up

@lordspace
Copy link

I am running a fresh Ubuntu 24 install from Linode and have the same issue: unexpected keyword argument 'chunked'

docker: 'compose' is not a docker command.

File "/usr/lib/python3/dist-packages/requests/sessions.py", line 602, in get
return self.request("GET", url, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/requests/sessions.py", line 589, in request
resp = self.send(prep, **send_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/requests/sessions.py", line 703, in send
r = adapter.send(request, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/requests/adapters.py", line 486, in send
resp = conn.urlopen(
^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 791, in urlopen
response = self._make_request(
^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 497, in _make_request
conn.request(
TypeError: HTTPConnection.request() got an unexpected keyword argument 'chunked'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/bin/docker-compose", line 33, in
sys.exit(load_entry_point('docker-compose==1.29.2', 'console_scripts', 'docker-compose')())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/compose/cli/main.py", line 81, in main
command_func()
File "/usr/lib/python3/dist-packages/compose/cli/main.py", line 200, in perform_command
project = project_from_options('.', options)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/compose/cli/command.py", line 60, in project_from_options
return get_project(
^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/compose/cli/command.py", line 152, in get_project
client = get_client(
^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/compose/cli/docker_client.py", line 41, in get_client
client = docker_client(
^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/compose/cli/docker_client.py", line 170, in docker_client
client = APIClient(use_ssh_client=not use_paramiko_ssh, **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'

@lordspace
Copy link

I wrote a short article about this error
https://wpsandbox.net/devops/how-to-fix-docker-errors-dockerexception-error-while-fetching-server-api-version-httpconnection-request-got-an-unexpected-keyword-argument-chunked-p1016

@slyfox1186
Copy link
Author

slyfox1186 commented May 29, 2024

I am running a fresh Ubuntu 24 install from Linode and have the same issue: unexpected keyword argument 'chunked'

docker: 'compose' is not a docker command.

Try using my installer script that installs the latest version of docker-compose from its official GitHub repository.

docker-compose-multi-arch.sh

This fixed my problem and you should be able to issue docker-compose and have it work this time.

@shamim-progton
Copy link

Thanks. I changed the code from docker-compose to docker compose and it works.

Thanks buddy it worked for me .

@Lalita5Kashyap
Copy link

  • docker-compose up -d
    Traceback (most recent call last):
    File "/usr/lib/python3/dist-packages/docker/api/client.py", line 214, in _retrieve_server_version
    return self.version(api_version=False)["ApiVersion"]
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/usr/lib/python3/dist-packages/docker/api/daemon.py", line 181, in version
    return self._result(self._get(url), json=True)
    ^^^^^^^^^^^^^^
    File "/usr/lib/python3/dist-packages/docker/utils/decorators.py", line 46, in inner
    return f(self, *args, **kwargs)
    ^^^^^^^^^^^^^^^^^^^^^^^^
    File "/usr/lib/python3/dist-packages/docker/api/client.py", line 237, in _get
    return self.get(url, **self._set_request_timeout(kwargs))
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/usr/lib/python3/dist-packages/requests/sessions.py", line 602, in get
    return self.request("GET", url, **kwargs)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/usr/lib/python3/dist-packages/requests/sessions.py", line 589, in request
    resp = self.send(prep, **send_kwargs)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/usr/lib/python3/dist-packages/requests/sessions.py", line 703, in send
    r = adapter.send(request, **kwargs)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/usr/lib/python3/dist-packages/requests/adapters.py", line 486, in send
    resp = conn.urlopen(
    ^^^^^^^^^^^^^
    File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 791, in urlopen
    response = self._make_request(
    ^^^^^^^^^^^^^^^^^^^
    File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 497, in _make_request
    conn.request(
    TypeError: HTTPConnection.request() got an unexpected keyword argument 'chunked'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/bin/docker-compose", line 33, in
sys.exit(load_entry_point('docker-compose==1.29.2', 'console_scripts', 'docker-compose')())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/compose/cli/main.py", line 81, in main
command_func()
File "/usr/lib/python3/dist-packages/compose/cli/main.py", line 200, in perform_command
project = project_from_options('.', options)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/compose/cli/command.py", line 60, in project_from_options
return get_project(
^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/compose/cli/command.py", line 152, in get_project
client = get_client(
^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/compose/cli/docker_client.py", line 41, in get_client
client = docker_client(
^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/compose/cli/docker_client.py", line 170, in docker_client
client = APIClient(use_ssh_client=not use_paramiko_ssh, **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'
Build step 'Execute shell' marked build as failure
Finished: FAILURE

@muhammadrivaldy
Copy link

You seem to be using an ancient version of docker-compose. Since you're getting a python stack dump this is a) nothing related to my image b) indicates you're using the he old python based tool. Upgrade your docker tooling and you'll find that docker compose is now a native command.

Waw, it works for me. Thanks bro!

@reaper-Chili
Copy link

Hi can u help me docker works in serv but fail like this / SSH + DOCKER ready inst and lastes
Run sshpass -p '' ssh -o StrictHostKeyChecking=no smith@ "
##[debug]/usr/bin/bash -e /home/runner/work/_temp/d0530b1d-a0f0-46eb-9674-8e7e299b6947.sh
[sudo] password for smith: Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/docker/api/client.py", line 214, in _retrieve_server_version
return self.version(api_version=False)["ApiVersion"]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/docker/api/daemon.py", line 181, in version
return self._result(self._get(url), json=True)
^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/docker/utils/decorators.py", line 46, in inner
return f(self, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/docker/api/client.py", line 237, in _get
return self.get(url, **self._set_request_timeout(kwargs))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/requests/sessions.py", line 602, in get
return self.request("GET", url, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/requests/sessions.py", line 589, in request
resp = self.send(prep, **send_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/requests/sessions.py", line 703, in send
r = adapter.send(request, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/requests/adapters.py", line 486, in send
resp = conn.urlopen(
^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 791, in urlopen
response = self._make_request(
^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 497, in _make_request
conn.request(
TypeError: HTTPConnection.request() got an unexpected keyword argument 'chunked'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/bin/docker-compose", line 33, in
sys.exit(load_entry_point('docker-compose==1.29.2', 'console_scripts', 'docker-compose')())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/compose/cli/main.py", line 81, in main
command_func()
File "/usr/lib/python3/dist-packages/compose/cli/main.py", line 200, in perform_command
project = project_from_options('.', options)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/compose/cli/command.py", line 60, in project_from_options
return get_project(
^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/compose/cli/command.py", line 152, in get_project
client = get_client(
^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/compose/cli/docker_client.py", line 41, in get_client
client = docker_client(
^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/compose/cli/docker_client.py", line 170, in docker_client
client = APIClient(use_ssh_client=not use_paramiko_ssh, **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'
Error: Process completed with exit code 1.

@itzg
Copy link
Owner

itzg commented Jul 9, 2024

Install the plugin with https://docs.docker.com/compose/install/ linux/ and use docker compose (without the dash) instead of docker-compose

@agambewe
Copy link

Thanks. I changed the code from docker-compose to docker compose and it works.

thx uu works for me

@JushBJJ
Copy link

JushBJJ commented Aug 20, 2024

If you're having docker: 'compose' is not a docker command. just install docker-compose-v2 if you're in ubuntu-based distros:

sudo apt install docker-compose-v2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
reason/external Closed because issue is caused by external factors
Projects
None yet
Development

No branches or pull requests

10 participants