一次docker-compose升级问题排查

发布时间:2020-07-19 10:47:43 作者:品鉴初心
来源:网络 阅读:2778

系统和docker信息

CentOS Linux release 7.5.1804 (Core)

Docker version 17.09.0-ce, build afdb6d4

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 -ddocker-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. docker-compose
  2. Docker-compose使用

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

docker docker-compose docker-compose升级报错

上一篇:Python标准库Difflib有坑? —— 两个方法快速提升数据对比效率

下一篇:bootstrap的Hello World

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》