扫二维码与项目经理沟通
我们在微信上24小时期待你的声音
解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流
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
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
from compose.cli.main import main
File "/usr/lib/python2.7/site-packages/compose/cli/main.py", line 22, in
from ..bundle import get_image_digests
File "/usr/lib/python2.7/site-packages/compose/bundle.py", line 13, in
from .network import get_network_defs_for_service
File "/usr/lib/python2.7/site-packages/compose/network.py", line 9, in
from docker.types import IPAMConfig
ImportError: cannot import name IPAMConfig
亦或者是这样的报错:
Traceback (most recent call last):
File "/usr/bin/docker-compose", line 7, in
from compose.cli.main import main
File "/usr/lib/python2.7/site-packages/compose/cli/main.py", line 17, in
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即可。另外有需要云服务器可以了解下创新互联cdcxhl.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。
我们在微信上24小时期待你的声音
解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流