如何利用yum源和pip安装 docker-compose

今天打算用docker部署一个东西,发现没安装docker-compose,于是安装了一翻。所以我的docker是之前就安装好的,记住啊,要先安装docker才可以安装 docker-compose。

首先添加EPEL源

yum install -y epel-release

然后安装python pip

yum install -y python-pip

安装docker-compose

pip install docker-compose

结果报错:Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-RdTF8W/distro/
You are using pip version 8.1.2, however version 23.2.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

 于是执行命令,这个是百度得到的可靠的答案

# 升级pip:
1.sudo wget https://bootstrap.pypa.io/pip/2.7/get-pip.py
2.sudo python get-pip.py
3.pip -V

# 升级pip3:
1.sudo wget https://bootstrap.pypa.io/pip/3.5/get-pip.py
2.sudo python3 get-pip.py
3.pip -V
然后执行安装命令pip install docker-compose

结果又抛出错

ERROR: Cannot uninstall 'subprocess32'. 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.

于是解决方案为

[root@localhost ~]# sudo find / -name *subpro*.egg-info
/usr/lib64/python2.7/site-packages/subprocess32-3.2.6-py2.7.egg-info
[root@localhost ~]# rm -rf /usr/lib64/python2.7/site-packages/subprocess32-3.2.6-py2.7.egg-info

然后再执行安装命令

又抛错ERROR: Cannot uninstall 'requests'. 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.

解决方案为

[root@localhost ~]# sudo find / -name *requests*.egg-info
/usr/lib/python2.7/site-packages/requests-2.6.0-py2.7.egg-info
[root@localhost ~]# rm -rf /usr/lib/python2.7/site-packages/requests-2.6.0-py2.7.egg-info

再执行安装命令

又抛错

ERROR: pip's legacy dependency resolver does not consider dependency conflicts when selecting packages. This behaviour is the source of the following dependency conflicts.
jsonschema 3.2.0 requires six>=1.11.0, but you'll have six 1.9.0 which is incompatible.
ipapython 4.6.8 requires dnspython>=1.15, but you'll have dnspython 1.12.0 which is incompatible.
ipapython 4.6.8 requires python-ldap>=3.0.0b1, but you'll have python-ldap 2.4.15 which is incompatible.
解决方案为

 pip install -i https://pypi.tuna.tsinghua.edu.cn/simple six>=1.11.0
 pip install -i https://pypi.tuna.tsinghua.edu.cn/simple dnspython>=1.15
 pip install -i https://pypi.tuna.tsinghua.edu.cn/simple python-ldap>=3.0.0b1

然后再次执行安装命令,安装成功

执行验证

[root@localhost ~]# docker-compose -version
 

你可能感兴趣的:(docker,容器,运维)