重庆分公司,新征程启航
为企业提供网站建设、域名注册、服务器等服务
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即可。