CentOS7下安装Docker-Compose

CentOS7下安装Docker-Compose

Docker-Compose是一个部署多个容器的简单但是非常必要的工具.

安装Docker-Compose之前,请先安装 python-pip

安装 python-pip

1、首先检查linux有没有安装python-pip包,终端执行 pip -V

1 [root@vm-50-151 network-scripts]# pip -V
2 -bash: pip: command not found

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

[root@vm-50-151 network-scripts]# yum -y install epel-release
Loaded plugins: fastestmirror, langpacks
base                                                                                                                                                                                            | 3.6 kB  00:00:00    
extras                                                                                                                                                                                          | 3.4 kB  00:00:00    
updates                                                                                                                                                                                         | 3.4 kB  00:00:00    
(1/2): extras/7/x86_64/primary_db                                                                                                                                                               | 129 kB  00:00:05    
(2/2): updates/7/x86_64/primary_db                                                                                                                                                              | 3.6 MB  00:00:09    
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.163.com
 * updates: mirrors.cn99.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
Downloading packages:
epel-release-7-9.noarch.rpm                                                                                                                                                                     |  14 kB  00:00:05    
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!

3、执行成功之后,再次执行yum -y install python-pip

[root@vm-50-151 network-scripts]# yum install python-pip
Loaded plugins: fastestmirror, langpacks
epel/x86_64/metalink                                                                                                                                                                            | 7.3 kB  00:00:00    
epel                                                                                                                                                                                            | 4.7 kB  00:00:00    
(1/3): epel/x86_64/group_gz                                                                                                                                                                     | 261 kB  00:00:01    
epel/x86_64/updateinfo         FAILED                                                        54% [=============================================-                                     ] 165 kB/s | 3.9 MB  00:00:20 ETA
http://ftp.riken.jp/Linux/fedora/epel/7/x86_64/repodata/ed160c344c46b2ec8d800367326ceaf25560b1515a0603a1e33a795b8b6492a1-updateinfo.xml.bz2: [Errno 12] Timeout on http://ftp.riken.jp/Linux/fedora/epel/7/x86_64/repodata/ed160c344c46b2ec8d800367326ceaf25560b1515a0603a1e33a795b8b6492a1-updateinfo.xml.bz2: (28, 'Operation too slow. Less than 1000 bytes/sec transferred the last 30 seconds')
Trying other mirror.
(2/3): epel/x86_64/updateinfo                                                                                                                                                                   | 845 kB  00:00:10    
(3/3): epel/x86_64/primary_db                                                                                                                                                                   | 6.1 MB  00:01:05    
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * epel: mirror01.idc.hinet.net
 * extras: mirrors.163.com
 * updates: mirrors.cn99.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:
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===========-                                ]  0.0 B/s | 1.3 MB  --:--:-- ETA
Public key for python2-pip-8.1.2-5.el7.noarch.rpm is not installed
(1/4): python2-pip-8.1.2-5.el7.noarch.rpm                                                                                                                                                       | 1.7 MB  00:00:00    
(2/4): python-backports-1.0-8.el7.x86_64.rpm                                                                                                                                                    | 5.8 kB  00:00:05    
(3/4): python-setuptools-0.9.8-7.el7.noarch.rpm                                                                                                                                                 | 397 kB  00:00:05    
(4/4): python-backports-ssl_match_hostname-3.4.0.2-4.el7.noarch.rpm                                                                                                                             |  12 kB  00:00:06    
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                                                  302 kB/s | 2.1 MB  00:00:07    
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!

4、对安装好的pip进行升级 pip install --upgrade pip
(我在这一步出现错误:提示说让You should consider upgrading via the ‘python -m pip install --upgrade pip’ command.输入python -m pip install --upgrade pip命令升级pip版本。但是输入之后仍然不可以。)
在这里插入图片描述
直接命令:**pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pip==20.1.1**升级,会给出一个命令:执行即可。

[root@centos7 etc]# pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pip==20.2.2
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting pip==20.2.2
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/5a/4a/39400ff9b36e719bdf8f31c99fe1fa7842a42fa77432e584f707a5080063/pip-20.2.2-py2.py3-none-any.whl (1.5 MB)
     |████████████████████████████████| 1.5 MB 166 kB/s 
Installing collected packages: pip
  Attempting uninstall: pip
    Found existing installation: pip 20.1.1
    Uninstalling pip-20.1.1:
      Successfully uninstalled pip-20.1.1
Successfully installed pip-20.2.2

至此,pip安装好了,执行pip -V 再次检查pip环境。

[root@centos7 etc]# pip -V
pip 20.2.2 from /usr/lib/python2.7/site-packages/pip (python 2.7)
[root@centos7 etc]# 

安装Docker-Compose
出现此错误:
ERROR: Could not find a version that satisfies the requirement websocket-client<1,>=0.32.0 (from docker-compose) (from versions: none) ERROR: No matching distribution found for websocket-client<1,>=0.32.0 (from docker-compose)

使用pip安装其他模块时也可能出现上述错误,主要原因是网络的问题,需要使用国内的镜像源来加速,比如豆瓣源

因此命令可以使用:
pip install docker-compose -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com
即可成功安装。

拜托关注一下,免费领取Java书籍与学习资料及阿里等大厂面试题
拜托关注一下,免费领取Java书籍与学习资料及阿里等大厂面试题。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值