Getting docker-compose TypeError: kwargs_from_env() got an unexpected keyword argument 'ssl_version' in GitLab
Asked Answered
F

4

27

I'm using GitLab CICD, in docker-test stage as defined docker_test: image: docker:stable services: - docker:stable-dind stage: docker-test ...

yesterday worked fine, but today - GitLab pipeline 'docker_test' fails with: TypeError: kwargs_from_env() got an unexpected keyword argument 'ssl_version'

I've found on the internet that it could be an upgrade to 7.0.0 https://docker-py.readthedocs.io/en/stable/change-log.html

Someone here suggested (for a different setup) downgrading to prev 6.3.1

After searching - have no idea how to do that. Maybe there are other solutions to this?

Forbore answered 11/12, 2023 at 17:7 Comment(0)
S
54

Summarising the discussion at docker-py:

Docker1 has made a change in v7.0.0 that breaks Docker Compose v1 written in Python (pip install docker-compose available as docker-compose). It has been deprecated and replaced by Docker Compose v2 implemented in Go which comes OOB as docker compose (sub-command).

Permanent fix: Switch to Docker Compose v2 (no extra installation required, read the migration docs to fix compatibility issues). Docker Compose v2 switch is totally worth, btw; it is a near implementation.

Temporary fix: Downgrade Docker1 using pip install docker==6.1.3 to the version that works with Docker Compose (v1).


Note: There is a request to provide backward compatibility — not sure if it will be accepted.

Credit: Tim Panohos's answer for the issue link.

1. Docker's python wrapper docker-py; not the real executable docker which is written in Go.

Stronghold answered 13/12, 2023 at 4:55 Comment(0)
M
8

Found this article on Git: https://github.com/docker/docker-py/issues/3194#issuecomment-1848950456

I got it to work by reverting the suggested change in the utils.py i.e. sudo nano ./usr/local/lib/python3.9/dist-packages/docker/utils/utils.py

Finding: def kwargs_from_env(environment=None):(See file docker/utils/utils.py line 344)

and adding: def kwargs_from_env(environment=None, ssl_version=None)

However, I think there is a reason for why its depreciated and probably due to encrytions have evolved - so I would try it get your project to run then revert back...?

Monostich answered 11/12, 2023 at 20:44 Comment(2)
Your solution was perfect and solved the problem. I could not downgrade my docker plugin because my docker host version is too much new and incompatible with older versions of docker plugin.Rhodos
On Windows: C:\ProgramData\Anaconda3\envs\<env_name>\Lib\site-packages\docker\utils\utils.pySelfknowledge
F
4

Thanks, everyone for the great ideas. This is how we've solved the problem:

As we did not want to downgrade to 6.1.3, we went and replaced docker-compose to docker compose cmd, but it failed to build as there was no supported argument '-f file.yml'.

it became clear that in GitLab CI/CD we were using image "docker:latest" which seems to have been built like 3 years ago and it supported docker client 18.smth

finally, we switched the image to image: docker:20.10.24 services: - docker:20.10.24-dind that we understood as the real latest stable version.

with the cleaning of some previous compatibility hacks it worked fine.

Forbore answered 13/12, 2023 at 13:9 Comment(1)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Guernsey
I
1

I got this error after upgrading to Ubuntu 20.04 and switchin from python2.7 to python 3.8. After googling, the fix is

sudo pip install --upgrade docker-py
Inmate answered 1/1 at 9:38 Comment(1)
Replace docker-py with docker to not run into this: github.com/docker/compose/issues/8366Oldster

© 2022 - 2024 — McMap. All rights reserved.