CentOS7下安装Docker-Compose

在使用Docker时,需要整体启动应用,一般会用到 docker-compose工具,如果是新安装的CentOS7是不会被安装的,但是安装这个工具的前提是要安装pip工具。

  • 首先检查CentOS7有没有安装python-pip包,直接执行yum install python-pip

[root@ds-163 ~]# yum install python-pip
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
No package python-pip available.
Error: Nothing to do

  • 没有python-pip包就执行命令 yum -y install epel-release

[root@ds-163 ~]# yum install epel-release
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
Resolving Dependencies
–> Running transaction check
—> Package epel-release.noarch 0:7-9 will be installed
–> Finished Dependency Resolution

Dependencies Resolved

===============================================================================================================================
Package Arch Version Repository Size
===============================================================================================================================
Installing:
epel-release noarch 7-9 extras 14 k

Transaction Summary
===============================================================================================================================
Install 1 Package

Total download size: 14 k
Installed size: 24 k
Is this ok [y/d/N]: y
Downloading packages:
epel-release-7-9.noarch.rpm | 14 kB 00:00:01
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : epel-release-7-9.noarch 1/1
Verifying : epel-release-7-9.noarch 1/1

Installed:
epel-release.noarch 0:7-9

Complete!

  • 执行成功之后,再次执行yum install python-pip

[root@ds-163 ~]# yum install python-pip
Loaded plugins: fastestmirror
epel/x86_64/metalink | 7.4 kB 00:00:00
epel | 4.7 kB 00:00:00
epel/x86_64/updateinfo FAILED
https://mirror.lzu.edu.cn/epel/7/x86_64/repodata/c933270bd133c8494e8684f1dc3a3829f939a62be7148a0f8640c691b61301c3-updateinfo.xml.bz2: [Errno 14] HTTPS Error 404 – Not Found
Trying other mirror.
To address this issue please refer to the below knowledge base article

https://access.redhat.com/articles/1320623

If above article doesn’t help to resolve this issue please create a bug on https://bugs.centos.org/

epel/x86_64/updateinfo FAILED ] 0.0 B/s | 0 B –:–:– ETA
http://ftp.riken.jp/Linux/fedora/epel/7/x86_64/repodata/c933270bd133c8494e8684f1dc3a3829f939a62be7148a0f8640c691b61301c3-updateinfo.xml.bz2: [Errno 14] HTTP Error 404 – Not Found
Trying other mirror.
(1/3): epel/x86_64/group_gz | 266 kB 00:00:00
epel/x86_64/updateinfo FAILED
http://ftp.jaist.ac.jp/pub/Linux/Fedora/epel/7/x86_64/repodata/c933270bd133c8494e8684f1dc3a3829f939a62be7148a0f8640c691b61301c3-updateinfo.xml.bz2: [Errno 14] HTTP Error 404 – Not Found
Trying other mirror.
(2/3): epel/x86_64/updateinfo | 879 kB 00:00:00
(3/3): epel/x86_64/primary_db | 6.2 MB 00:02:59
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* epel: mirror.lzu.edu.cn
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
Resolving Dependencies
–> Running transaction check
—> Package python2-pip.noarch 0:8.1.2-5.el7 will be installed
–> Processing Dependency: python-setuptools for package: python2-pip-8.1.2-5.el7.noarch
–> Running transaction check
—> Package python-setuptools.noarch 0:0.9.8-7.el7 will be installed
–> Processing Dependency: python-backports-ssl_match_hostname for package: python-setuptools-0.9.8-7.el7.noarch
–> Running transaction check
—> Package python-backports-ssl_match_hostname.noarch 0:3.4.0.2-4.el7 will be installed
–> Processing Dependency: python-backports for package: python-backports-ssl_match_hostname-3.4.0.2-4.el7.noarch
–> Running transaction check
—> Package python-backports.x86_64 0:1.0-8.el7 will be installed
–> Finished Dependency Resolution

Dependencies Resolved

===============================================================================================================================
Package Arch Version Repository Size
===============================================================================================================================
Installing:
python2-pip noarch 8.1.2-5.el7 epel 1.7 M
Installing for dependencies:
python-backports x86_64 1.0-8.el7 base 5.8 k
python-backports-ssl_match_hostname noarch 3.4.0.2-4.el7 base 12 k
python-setuptools noarch 0.9.8-7.el7 base 397 k

Transaction Summary
===============================================================================================================================
Install 1 Package (+3 Dependent packages)

Total download size: 2.1 M
Installed size: 9.1 M
Is this ok [y/d/N]: y
Downloading packages:
(1/4): python-backports-1.0-8.el7.x86_64.rpm | 5.8 kB 00:00:00
(2/4): python-backports-ssl_match_hostname-3.4.0.2-4.el7.noarch.rpm | 12 kB 00:00:00
(3/4): python-setuptools-0.9.8-7.el7.noarch.rpm | 397 kB 00:00:00
warning: /var/cache/yum/x86_64/7/epel/packages/python2-pip-8.1.2-5.el7.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID 352c64e5: NOKEY
Public key for python2-pip-8.1.2-5.el7.noarch.rpm is not installed
(4/4): python2-pip-8.1.2-5.el7.noarch.rpm | 1.7 MB 00:00:01
——————————————————————————————————————————-
Total 1.0 MB/s | 2.1 MB 00:00:02
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
Importing GPG key 0x352C64E5:
Userid : “Fedora EPEL (7) <epel@fedoraproject.org>”
Fingerprint: 91e9 7d7c 4a5e 96f1 7f3e 888f 6a2f aea2 352c 64e5
Package : epel-release-7-9.noarch (@extras)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
Is this ok [y/N]: y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : python-backports-1.0-8.el7.x86_64 1/4
Installing : python-backports-ssl_match_hostname-3.4.0.2-4.el7.noarch 2/4
Installing : python-setuptools-0.9.8-7.el7.noarch 3/4
Installing : python2-pip-8.1.2-5.el7.noarch 4/4
Verifying : python2-pip-8.1.2-5.el7.noarch 1/4
Verifying : python-setuptools-0.9.8-7.el7.noarch 2/4
Verifying : python-backports-1.0-8.el7.x86_64 3/4
Verifying : python-backports-ssl_match_hostname-3.4.0.2-4.el7.noarch 4/4

Installed:
python2-pip.noarch 0:8.1.2-5.el7

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!

  • 对安装好的pip进行升级 pip install –upgrade pip

[root@ds-163 ~]# pip install –upgrade pip
Collecting pip
Downloading pip-9.0.1-py2.py3-none-any.whl (1.3MB)
91% |鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枎 | 1.1MB 935kB/s eta 0:00:0 92% |鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枌 | 1.2MB 942kB/s eta 0:00:0 93% |鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枈 | 1.2MB 863kB/s eta 0:00:0 93% |鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅 | 1.2MB 770kB/s eta 0:00:0 94% |鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻| 1.2MB 801kB/s eta 0:00:0 95% |鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻| 1.2MB 896kB/s eta 0:00:0 96% |鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻| 1.2MB 897kB/s eta 0:00:0 97% |鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻| 1.2MB 859kB/s eta 0:00:0 97% |鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枍| 1.2MB 781kB/s eta 0: 98% |鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枊| 1.2MB 1.2MB/s eta 0: 99% |鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枆| 1.2MB 1.3MB/s eta 0: 100% |鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅| 1.3MB 526kB/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-9.0.1

pip工具就安装完成。

  • 安装docker-compose,终端直接输入 pip install docker-compose

[root@ds-163 ~]# pip install docker-compose
Collecting docker-compose
Downloading docker_compose-1.18.0-py2.py3-none-any.whl (111kB)
91% |鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枎 | 102kB 355kB/s eta 0:00:0 100% |鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅| 112kB 359kB/s
Collecting websocket-client<1.0,>=0.32.0 (from docker-compose)
Downloading websocket_client-0.46.0-py2.py3-none-any.whl (200kB)
91% |鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枍 | 184kB 1.2MB/s eta 0:00:0 97% |鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻| 194kB 1.2MB/s eta 0:00:0 100% |鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅| 204kB 810kB/s
Collecting docker<3.0,>=2.6.1 (from docker-compose)
Downloading docker-2.7.0-py2.py3-none-any.whl (119kB)
94% |鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻| 112kB 391kB/s eta 0:00:0 100% |鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅| 122kB 372kB/s
Collecting backports.ssl-match-hostname>=3.5; python_version < “3.5” (from docker-compose)
Downloading backports.ssl_match_hostname-3.5.0.1.tar.gz
Collecting PyYAML<4,>=3.10 (from docker-compose)
Downloading PyYAML-3.12.tar.gz (253kB)
93% |鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枆 | 235kB 624kB/s eta 0:00:0 97% |鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻| 245kB 566kB/s eta 0:00:0 100% |鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅| 256kB 527kB/s
Collecting dockerpty<0.5,>=0.4.1 (from docker-compose)
Downloading dockerpty-0.4.1.tar.gz
Collecting ipaddress>=1.0.16; python_version < “3.3” (from docker-compose)
Downloading ipaddress-1.0.19.tar.gz
Collecting docopt<0.7,>=0.6.1 (from docker-compose)
Downloading docopt-0.6.2.tar.gz
Collecting enum34<2,>=1.0.4; python_version < “3.4” (from docker-compose)
Downloading enum34-1.1.6-py2-none-any.whl
Collecting requests!=2.11.0,!=2.12.2,!=2.18.0,<2.19,>=2.6.1 (from docker-compose)
Downloading requests-2.18.4-py2.py3-none-any.whl (88kB)
100% |鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅| 92kB 87kB/s
Collecting texttable<0.10,>=0.9.0 (from docker-compose)
Downloading texttable-0.9.1.tar.gz
Collecting cached-property<2,>=1.2.0 (from docker-compose)
Downloading cached_property-1.3.1-py2.py3-none-any.whl
Collecting jsonschema<3,>=2.5.1 (from docker-compose)
Downloading jsonschema-2.6.0-py2.py3-none-any.whl
Collecting six<2,>=1.3.0 (from docker-compose)
Downloading six-1.11.0-py2.py3-none-any.whl
Collecting docker-pycreds>=0.2.1 (from docker<3.0,>=2.6.1->docker-compose)
Downloading docker_pycreds-0.2.1-py2.py3-none-any.whl
Collecting certifi>=2017.4.17 (from requests!=2.11.0,!=2.12.2,!=2.18.0,<2.19,>=2.6.1->docker-compose)
Downloading certifi-2018.1.18-py2.py3-none-any.whl (151kB)
94% |鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻| 143kB 181kB/s eta 0:00:0 100% |鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅| 153kB 174kB/s
Collecting chardet<3.1.0,>=3.0.2 (from requests!=2.11.0,!=2.12.2,!=2.18.0,<2.19,>=2.6.1->docker-compose)
Downloading chardet-3.0.4-py2.py3-none-any.whl (133kB)
92% |鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枌 | 122kB 154kB/s eta 0:00:0 99% |鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅| 133kB 167kB/s eta 0: 100% |鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅| 143kB 187kB/s
Collecting idna<2.7,>=2.5 (from requests!=2.11.0,!=2.12.2,!=2.18.0,<2.19,>=2.6.1->docker-compose)
Downloading idna-2.6-py2.py3-none-any.whl (56kB)
100% |鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅| 61kB 160kB/s
Collecting urllib3<1.23,>=1.21.1 (from requests!=2.11.0,!=2.12.2,!=2.18.0,<2.19,>=2.6.1->docker-compose)
Downloading urllib3-1.22-py2.py3-none-any.whl (132kB)
92% |鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枈 | 122kB 157kB/s eta 0:00:0 100% |鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅| 133kB 146kB/s
Collecting functools32; python_version == “2.7” (from jsonschema<3,>=2.5.1->docker-compose)
Downloading functools32-3.2.3-2.zip
Installing collected packages: six, websocket-client, backports.ssl-match-hostname, docker-pycreds, certifi, chardet, idna, urllib3, requests, ipaddress, docker, PyYAML, dockerpty, docopt, enum34, texttable, cached-property, functools32, jsonschema, docker-compose
Found existing installation: backports.ssl-match-hostname 3.4.0.2
Uninstalling backports.ssl-match-hostname-3.4.0.2:
Successfully uninstalled backports.ssl-match-hostname-3.4.0.2
Running setup.py install for backports.ssl-match-hostname … done
Found existing installation: chardet 2.2.1
Uninstalling chardet-2.2.1:
Successfully uninstalled chardet-2.2.1
Running setup.py install for ipaddress … done
Running setup.py install for PyYAML … done
Running setup.py install for dockerpty … done
Running setup.py install for docopt … 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 certifi-2018.1.18 chardet-3.0.4 docker-2.7.0 docker-compose-1.18.0 docker-pycreds-0.2.1 dockerpty-0.4.1 docopt-0.6.2 enum34-1.1.6 functools32-3.2.3.post2 idna-2.6 ipaddress-1.0.19 jsonschema-2.6.0 requests-2.18.4 six-1.11.0 texttable-0.9.1 urllib3-1.22 websocket-client-0.46.0

注意:执行docker-compse可能会出现错误,需要在更新命令行,在终端直接输入 pip install –upgrade backports.ssl_match_hostname

  • 确认版本

[root@ds-163 ~]# docker-compose -version
docker-compose version 1.18.0, build 8dd22a9