您好,登錄后才能下訂單哦!
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進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。