您好,登录后才能下订单哦!
cat /etc/redhat-release
:CentOS Linux release 7.5.1804 (Core)
docker --version
:Docker version 17.09.0-ce, build afdb6d4
docker-compose version
:docker-compose version 1.23.2, build 1110ad0
docker-py version: 3.7.0
CPython version: 2.7.5
OpenSSL version: OpenSSL 1.0.2k-fips 26 Jan 2017
最近由于开发同学项目需求,需要将docker-compose
版本从1.12.x升级至1.21.x(21版本以上,目前是1.23.2)~
pip install --upgrade pip
pip install docker-compose==1.23.2
出现如下报错:
Cannot uninstall 'texttable'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.
解决方法:
进入/usr/lib/python(你的版本号)/site-packages/目录
,直接删包目录:
rm -rf texttable-*.egg-info
pip install docker-compose==1.23.2
此时,我们使用docker-compose version
命令是正常的,但是当我们进入docker-compose.yml文件路径,执行docker-compose up -d
或docker-compose ps
时,出现如下报错:
Traceback (most recent call last):
File "/usr/bin/docker-compose", line 10, in <module>
sys.exit(main())
File "/usr/lib/python2.7/site-packages/compose/cli/main.py", line 71, in main
command()
File "/usr/lib/python2.7/site-packages/compose/cli/main.py", line 124, in perform_command
project = project_from_options('.', options)
或者是这样的报错:
Traceback (most recent call last):
File "/usr/bin/docker-compose", line 6, in <module>
from compose.cli.main import main
File "/usr/lib/python2.7/site-packages/compose/cli/main.py", line 22, in <module>
from ..bundle import get_image_digests
File "/usr/lib/python2.7/site-packages/compose/bundle.py", line 13, in <module>
from .network import get_network_defs_for_service
File "/usr/lib/python2.7/site-packages/compose/network.py", line 9, in <module>
from docker.types import IPAMConfig
ImportError: cannot import name IPAMConfig
亦或者是这样的报错:
Traceback (most recent call last):
File "/usr/bin/docker-compose", line 7, in <module>
from compose.cli.main import main
File "/usr/lib/python2.7/site-packages/compose/cli/main.py", line 17, in <module>
import docker
ImportError: No module named docker
最终的结果都是一样的,就是docker-compose无法使用~~
为了不碰到上面棘手的报错,正确升级姿势总结如下:
主要步骤如下:
(1)使用pip list|grep docker
查看已安装相关docker包信息
(2)手动卸载第一步列出来的包,如下:
<1> pip uninstall docker
<2> pip uninstall docker-compose
<3> pip uninstall docker-py
<4> pip uninstall docker-pycreds
<5> pip uninstall dockerpty
(3)安装docker-compose:pip install docker-compose==1.23.2 -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com
#<== 这里使用豆瓣的源,比较快~
Cannot uninstall 'texttable'
,请执行上面提到的解决方法~,然后再次安装docker-compose即可。免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。