geerlingguy / ansible-role-docker

Ansible Role - Docker
https://galaxy.ansible.com/geerlingguy/docker/
MIT License
1.85k stars 858 forks source link

Encountering "Error while fetching server API version: Not supported URL scheme http+docker" #462

Open mhorlacher opened 5 months ago

mhorlacher commented 5 months ago

I'm using version 7.2.0 - I imagine this is related to this issue https://github.com/docker/docker-py/issues/3256? Machine is running ubuntu-22.04. Full traceback pasted below.

vagrant@node-1:/services$ docker-compose up
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/requests/adapters.py", line 633, in send
    conn = self.get_connection_with_tls_context(
  File "/usr/local/lib/python3.10/dist-packages/requests/adapters.py", line 489, in get_connection_with_tls_context
    conn = self.poolmanager.connection_from_host(
  File "/usr/lib/python3/dist-packages/urllib3/poolmanager.py", line 245, in connection_from_host
    return self.connection_from_context(request_context)
  File "/usr/lib/python3/dist-packages/urllib3/poolmanager.py", line 257, in connection_from_context
    raise URLSchemeUnknown(scheme)
urllib3.exceptions.URLSchemeUnknown: Not supported URL scheme http+docker

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/docker/api/client.py", line 214, in _retrieve_server_version
    return self.version(api_version=False)["ApiVersion"]
  File "/usr/local/lib/python3.10/dist-packages/docker/api/daemon.py", line 181, in version
    return self._result(self._get(url), json=True)
  File "/usr/local/lib/python3.10/dist-packages/docker/utils/decorators.py", line 46, in inner
    return f(self, *args, **kwargs)
  File "/usr/local/lib/python3.10/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/sessions.py", line 602, in get
    return self.request("GET", url, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/requests/sessions.py", line 589, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python3.10/dist-packages/requests/sessions.py", line 703, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/requests/adapters.py", line 637, in send
    raise InvalidURL(e, request=request)
requests.exceptions.InvalidURL: Not supported URL scheme http+docker

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/bin/docker-compose", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.10/dist-packages/compose/cli/main.py", line 81, in main
    command_func()
  File "/usr/local/lib/python3.10/dist-packages/compose/cli/main.py", line 200, in perform_command
    project = project_from_options('.', options)
  File "/usr/local/lib/python3.10/dist-packages/compose/cli/command.py", line 60, in project_from_options
    return get_project(
  File "/usr/local/lib/python3.10/dist-packages/compose/cli/command.py", line 152, in get_project
    client = get_client(
  File "/usr/local/lib/python3.10/dist-packages/compose/cli/docker_client.py", line 41, in get_client
    client = docker_client(
  File "/usr/local/lib/python3.10/dist-packages/compose/cli/docker_client.py", line 170, in docker_client
    client = APIClient(use_ssh_client=not use_paramiko_ssh, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/docker/api/client.py", line 197, in __init__
    self._version = self._retrieve_server_version()
  File "/usr/local/lib/python3.10/dist-packages/docker/api/client.py", line 221, in _retrieve_server_version
    raise DockerException(
docker.errors.DockerException: Error while fetching server API version: Not supported URL scheme http+docker

Packages:

vagrant@node-1:/services$ pip list
Package            Version
------------------ -------------
attrs              21.2.0
Automat            20.2.0
Babel              2.8.0
bcrypt             3.2.0
blinker            1.4
certifi            2020.6.20
cffi               1.16.0
chardet            4.0.0
charset-normalizer 3.3.2
click              8.0.3
cloud-init         24.1.3
colorama           0.4.4
configobj          5.0.6
constantly         15.1.0
cryptography       3.4.8
dbus-python        1.2.18
distro             1.7.0
docker             6.1.3
docker-compose     1.29.2
dockerpty          0.4.1
docopt             0.6.2
httplib2           0.20.2
hyperlink          21.0.0
idna               3.3
importlib-metadata 4.6.4
incremental        21.3.0
jeepney            0.7.1
Jinja2             3.0.3
jsonpatch          1.32
jsonpointer        2.0
jsonschema         3.2.0
keyring            23.5.0
launchpadlib       1.10.16
lazr.restfulclient 0.14.4
lazr.uri           1.0.6
MarkupSafe         2.0.1
more-itertools     8.10.0
netifaces          0.11.0
oauthlib           3.2.0
packaging          24.0
paramiko           3.4.0
pexpect            4.8.0
pip                22.0.2
ptyprocess         0.7.0
pyasn1             0.4.8
pyasn1-modules     0.2.1
pycparser          2.22
PyGObject          3.42.1
PyHamcrest         2.0.2
PyJWT              2.3.0
PyNaCl             1.5.0
pyOpenSSL          21.0.0
pyparsing          2.4.7
pyrsistent         0.18.1
pyserial           3.5
python-apt         2.4.0+ubuntu3
python-dotenv      0.21.1
python-magic       0.4.24
pytz               2022.1
PyYAML             5.4.1
requests           2.31.0
SecretStorage      3.3.1
service-identity   18.1.0
setuptools         59.6.0
six                1.16.0
sos                4.5.6
ssh-import-id      5.11
systemd-python     234
texttable          1.7.0
Twisted            22.1.0
ubuntu-pro-client  8001
ufw                0.36.1
urllib3            1.26.5
wadllib            1.3.6
websocket-client   0.59.0
wheel              0.37.1
zipp               1.0.0
zope.interface     5.4.0
aaronflorey commented 5 months ago

temporary fix it to install requests version 2.31.0 - which fixed it for me. Might need a lower version to fix it for you.

Korrd commented 5 months ago

Having the same issue here!

gkarumbi commented 4 months ago

temporary fix it to install requests version 2.31.0 - which fixed it for me. Might need a lower version to fix it for you.

This worked for me.

davetapley commented 3 months ago

I had the scheme error, but:

    pip_install_packages:
      - name: requests
        version: "2.31.0"

Then caused:

Error connecting: Error while fetching server API version:
request() got an unexpected keyword argument 'chunked'

Presumably:

Not sure why fix isn't there, but downgrading again resolved that issue:

    pip_install_packages:
      - name: requests
        version: "2.29.0"