Score:4

How to silence or fix snap docker-compose CryptographyDeprecationWarning: Python 3.6 is no longer supported

pt flag

My Ubuntu server runs docker installed with snap. Recently I noticed that running docker-compose brings up a Python related warning, for example:

$ docker-compose version
/snap/docker/2285/lib/python3.6/site-packages/paramiko/transport.py:33: CryptographyDeprecationWarning: Python 3.6 is no longer supported by the Python core team. Therefore, support for it is deprecated in cryptography and will be removed in a future release.
  from cryptography.hazmat.backends import default_backend
docker-compose version 1.29.2, build unknown
docker-py version: 5.0.3
CPython version: 3.6.9
OpenSSL version: OpenSSL 1.1.1  11 Sep 2018

My Python version is higher:

$ python3 --version
Python 3.10.6

And:

$ docker version
Client:
 Version:           20.10.17
 API version:       1.41
 Go version:        go1.16.15
 Git commit:        100c70180f
 Built:             Thu Sep 22 06:21:41 2022
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server:
 Engine:
  Version:          20.10.17
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.16.15
  Git commit:       a89b842
  Built:            Thu Sep 22 06:22:13 2022
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          v1.6.6
  GitCommit:        10c12954828e7c7c9b6e0ea9b0c02b01407d3ae1
 runc:
  Version:          1.1.2
  GitCommit:
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

I saw a comment on a GitHub issue about using pip to reinstall docker-compose but I don't think that would help here since I didn't install it with pip:

$ pip3 list
Command 'pip3' not found, but can be installed with:
sudo apt install python3-pip

$ pip list
Command 'pip' not found, but can be installed with:
sudo apt install python3-pip

As far as I know, the docker-compose plugin is included with the docker snap. For now I just shut it up with:

alias docker-compose="docker-compose 2>/dev/null"

But this can hide other errors and I'd prefer an actual fix. Would appreciate any ideas.

Score:8
vn flag

The command docker-compose is the old, deprecated version of Docker Compose.

Instead, try and run docker compose version. This should give you the version of the current release (2.X) of Docker Compose.

You could create an alias to map the old syntax to the new version, like this:

alias docker-compose='docker compose'

Maybe the old release is included for compatibility, but I would recommend to only use the new 2.X version.

Nagev avatar
pt flag
They should mention the change in the [documentation](https://docs.docker.com/compose/gettingstarted/). Even though they use the newer command and it's even listed in `docker --help`, it's so easy to miss the difference! Better still, they could just remove the old plugin or replace it with a notification. Thanks, using the new command from now on, it's also nicer!
Artur Meinild avatar
vn flag
Happy to hear it worked for you! Unfortunately, I see a lot of documentation not being updated to the new syntax, so having the mentioned alias can help a lot.
Nagev avatar
pt flag
For sure, it's helpful, there may be scripts etc. that still use the old syntax. In my case I just used `vim` to replace all my aliases in `.bashrc` that used the old `docker-compose` with `docker compose`.
Nagev avatar
pt flag
Not sure when the change was announced but this post seems to be related: https://www.docker.com/blog/announcing-compose-v2-general-availability/
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.