我的 Ubuntu 服务器运行安装了折断最近发现运行docker-compose
会出现Python相关的警告,例如:
$ 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
我的Python版本较高:
$ python3 --version
Python 3.10.6
和:
$ 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
我看到一条评论GitHub 问题关于使用pip
重新安装docker-compose
,但我不认为这在这里有帮助,因为我没有用它安装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
据我所知,该docker-compose
插件包含在docker snap中。现在我只能用以下方法关闭它:
alias docker-compose="docker-compose 2>/dev/null"
但这可能会隐藏其他错误,我更希望得到实际修复。任何想法都值得感激。
答案1
该命令docker-compose
是 Docker Compose 的旧版本,已弃用。
相反,尝试运行docker compose version
。这将为您提供 Docker Compose 当前版本 (2.X) 的版本。
您可以创建一个别名来将旧语法映射到新版本,如下所示:
alias docker-compose='docker compose'
也许旧版本是为了兼容性而包含的,但我建议仅使用新的 2.X 版本。