我安装了python 2.7和docker 19.03。打印(docker.version)显示docker的错误版本。
root@block1:# docker --version
Docker version 19.03.13, build 4484c46d9d
root@block1:# python
Python 2.7.17 (default, Oct 8 2020, 12:12:24)
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import docker
>>> print(docker.__version__)
1.10.6
>>>我喜欢强制python显示19.03.13。
发布于 2020-12-01 06:38:08
docker.version返回您安装的"docker“Python包的版本,似乎是1.10.6。
如果需要docker守护进程的版本,可以使用from_env方法连接到它,然后从客户端查询版本:
>>> import docker
>>> docker.version # This is the version of the Python package
'4.4.0'
>>> client = docker.from_env()
>>> client.version()['Version'] # And this is the version of docker
'19.03.13'https://stackoverflow.com/questions/65082091
复制相似问题