CentOS7下安装Docker-Compose
Docker-Compose是一个部署多个容器的简单但是非常必要的工具。
安装Docker-Compose之前,请先安装 python-pip
安装 python-pip
1、首先检查linux有没有安装python-pip包,终端执行 pip -V
[root@gm]# pip -V
-bash: pip: command not found
2、没有python-pip包就执行命令 yum -y install epel-release
[root@gm]# yum -y install epel-release Loaded plugins: fastestmirror, langpacks
...
...
...
Complete!
3、执行成功之后,再次执行yum -y install python-pip
[root@gm]# yum install python-pip Loaded plugins: fastestmirror, langpacks . . . Dependency Installed: python-backports.x86_64 0:1.0-8.el7 python-backports-ssl_match_hostname.noarch 0:3.4.0.2-4.el7 python-setuptools.noarch 0:0.9.8-7.el7 Complete!
4、对安装好的pip进行升级 pip install --upgrade pip
[root@gm]# pip install --upgrade pip Collecting pip Downloading https://files.pythonhosted.org/packages/0f/74/ecd13431bcc456ed390b44c8a6e917c1820365cbebcb6a8974d1cd045ab4/pip-10.0.1-py2.py3-none-any.whl (1.3MB) 100% |████████████████████████████████| 1.3MB 225kB/s Installing collected packages: pip Found existing installation: pip 8.1.2 Uninstalling pip-8.1.2: Successfully uninstalled pip-8.1.2 Successfully installed pip-10.0.1
至此,pip安装好了,执行pip -V 再次检查pip环境。
[root@gm]# pip -V pip 10.0.1 from /usr/lib/python2.7/site-packages/pip (python 2.7)
安装Docker-Compose
1.终端执行:pip install docker-compose
报错:ReadTimeoutError: HTTPSConnectionPool(host='pypi.python.org', port=443): Read timed out
解决:pip --default-timeout=200 install -U docker-compose
[root@gm]# pip --default-timeout=200 install -U docker-compose Collecting docker-compose . . . Running setup.py install for backports.ssl-match-hostname ... done Running setup.py install for texttable ... done Running setup.py install for functools32 ... done Successfully installed PyYAML-3.12 backports.ssl-match-hostname-3.5.0.1 cached-property-1.3.1 docker-2.6.1 docker-compose-1.17.1 docker-pycreds-0.2.1 dockerpty-0.4.1 docopt-0.6.2 enum34-1.1.6 functools32-3.2.3.post2 ipaddress-1.0.18 jsonschema-2.6.0 requests-2.11.1 six-1.11.0 texttable-0.9.1 websocket-client-0.44.0
检查docker-compose 安装:docker-compose -version
[root@gm]# docker-compose -version docker-compose version 1.21.2, build a133471
如果报错
pkg_resources.DistributionNotFound: backports.ssl-match-hostname>=3.5
解决方法:更新backports.ssl-match-hostname的版本,在终端输入命令
pip install --upgrade backports.ssl_match_hostname
如若python版本过低,需升级,见:http://www.cnblogs.com/YatHo/p/8257387.html