Docker-compose unexpected keyword argument ‘ssl_version’

brainframe compose up returns the following failure,

docker-compose --file /usr/local/share/brainframe/docker-compose.yml --env-file /usr/local/share/brainframe/.env up
Traceback (most recent call last):
File “.local/bin/docker-compose”, line 8, in
sys.exit(main())
File “.local/lib/python3.8/site-packages/compose/cli/main.py”, line 81, in main
command_func()
File “.local/lib/python3.8/site-packages/compose/cli/main.py”, line 200, in perform_command
project = project_from_options(‘.’, options)
File “.local/lib/python3.8/site-packages/compose/cli/command.py”, line 60, in project_from_options
return get_project(
File “.local/lib/python3.8/site-packages/compose/cli/command.py”, line 152, in get_project
client = get_client(
File “.local/lib/python3.8/site-packages/compose/cli/docker_client.py”, line 41, in get_client
client = docker_client(
File “.local/lib/python3.8/site-packages/compose/cli/docker_client.py”, line 124, in docker_client
kwargs = kwargs_from_env(environment=environment, ssl_version=tls_version)
TypeError: kwargs_from_env() got an unexpected keyword argument ‘ssl_version’

Or “Not supported URL scheme http+docker” failure when running brainframe compose up,

docker-compose --file /usr/local/share/brainframe/docker-compose.yml --env-file /usr/local/share/brainframe/.env up
Traceback (most recent call last):
File “.local/lib/python3.8/site-packages/requests/adapters.py”, line 633, in send
conn = self.get_connection_with_tls_context(
File “.local/lib/python3.8/site-packages/requests/adapters.py”, line 489, in get_connection_with_tls_context
conn = self.poolmanager.connection_from_host(
File “/usr/local/lib/python3.8/dist-packages/urllib3/poolmanager.py”, line 245, in connection_from_host
return self.connection_from_context(request_context)
File “/usr/local/lib/python3.8/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 “.local/lib/python3.8/site-packages/docker/api/client.py”, line 214, in _retrieve_server_version
return self.version(api_version=False)[“ApiVersion”]
File “.local/lib/python3.8/site-packages/docker/api/daemon.py”, line 181, in version
return self._result(self._get(url), json=True)
File “.local/lib/python3.8/site-packages/docker/utils/decorators.py”, line 46, in inner
return f(self, *args, **kwargs)
File “.local/lib/python3.8/site-packages/docker/api/client.py”, line 237, in _get
return self.get(url, **self._set_request_timeout(kwargs))
File “.local/lib/python3.8/site-packages/requests/sessions.py”, line 602, in get
return self.request(“GET”, url, **kwargs)
File “.local/lib/python3.8/site-packages/requests/sessions.py”, line 589, in request
resp = self.send(prep, **send_kwargs)
File “.local/lib/python3.8/site-packages/requests/sessions.py”, line 703, in send
r = adapter.send(request, **kwargs)
File “.local/lib/python3.8/site-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 “.local/bin/docker-compose”, line 8, in
sys.exit(main())
File “.local/lib/python3.8/site-packages/compose/cli/main.py”, line 81, in main
command_func()
File “.local/lib/python3.8/site-packages/compose/cli/main.py”, line 200, in perform_command
project = project_from_options(‘.’, options)
File “.local/lib/python3.8/site-packages/compose/cli/command.py”, line 60, in project_from_options
return get_project(
File “.local/lib/python3.8/site-packages/compose/cli/command.py”, line 152, in get_project
client = get_client(
File “.local/lib/python3.8/site-packages/compose/cli/docker_client.py”, line 41, in get_client
client = docker_client(
File “.local/lib/python3.8/site-packages/compose/cli/docker_client.py”, line 170, in docker_client
client = APIClient(use_ssh_client=not use_paramiko_ssh, **kwargs)
File “.local/lib/python3.8/site-packages/docker/api/client.py”, line 197, in init
self._version = self._retrieve_server_version()
File “.local/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: Not supported URL scheme http+docker

BrainFrame uses docker to isolate itself from the host machine environment. Depending on what is available in the host system, “brainframe compose up” uses one of the commands below:

Docker Compose V1,

docker-compose --file /usr/local/share/brainframe/docker-compose.yml --env-file /usr/local/share/brainframe/.env up

Docker Compose V2,

docker compose --file /usr/local/share/brainframe/docker-compose.yml --env-file /usr/local/share/brainframe/.env up

The docker compose failure often is caused by the compatibility of various docker components installed on the host, e.g. docker server, CLI and compose module. Conflicting versions of the modules can cause issues in this post . Here’s how we can troubleshoot and resolve the version compatibility issues:

1 Reinstall Docker Python Packages

Uninstall Existing Packages:

pip uninstall docker docker-compose

You may need to run the uninstall command multiple times if the packages are installed in multiple locations. Then install Specific Compatible Versions:

pip install docker==6.1.3 docker-compose==1.29.2

2 Use Docker Compose V2 (Optional but Recommended)

Docker Compose V2 is now integrated as a Docker plugin and doesn’t rely on Python dependencies. Install Docker Compose V2:

sudo apt-get update
sudo apt-get install docker-compose-plugin

Verify Installation:

docker compose version

Note that the command with V2 is docker compose (space instead of hyphen).

3 Explanation of the docker & docker compose versions

Ensure that you’re using compatible versions. Observation of the compatible latest releases in Dec., 2024

Ubuntu        | docker engine | docker compose | docker python SDK
18.04 & 20.04 | 24.0.7        | V1: v1.29.2    | >4.3.1,<7.0.0, 6.1.3 is the latest version
22.04 & 24.04 | 27.3.1        | V2: v2.29.7    | 6.1.3 and possibly a few older versions

3.1 docker engine versions

docker version --format '{{.Server.Version}}'    # engine version
docker version --format '{{.Server.APIVersion}}' # engine API version

Noticed that docker engine installation includes docker CLI, and docker compose V2 has been integrated.

3.2 docker CLI versions

docker version --format '{{.Client.Version}}'    # CLI version
docker version --format '{{.Client.APIVersion}}' # CLI API version
docker --version # CLI version

3.3 docker compose V1 version

Install docker compose V1 with the pip command below. docker-compose python package is compose V1, including docker-compose CLI tool + python API, latest known good compose V1 version 1.29.2

pip install docker-compose

Check docker compose V1 version,

docker-compose --version # compose V1 version

Or use any of below commands:

docker-compose version # Also shows version of docker-py, CPython, OpenSSL version
python3 -m compose --version
pip show docker-compose

docker python module version & docker-compose python module version

docker python module is docker SDK for python. Install docker python SDK with the command below. This module includes some compose functionality, but NOT compose up/down. You cannot execute the docker pip module directly

pip install docker

docker-compose module depends on docker SDK python module
docker-compose module is compatible with docker SDK >4.3.1,<7.0.0
docker-compose module is not compatible with docker SDK 7.0.0/7.1.0
docker SDK python module 6.1.3 is the latest version compatible with both compose V1 and V2

3.4 Docker compose V2 version

Docker compose V2 has been integrated as a docker plugin

docker compose version # compose V2 version