介绍:

  • Compose 支持 Linux、macOS、Windows 10 三大平台。

本文只安装linux平台

  • Compose 可以通过 Python 的包管理工具 pip 进行安装,也可以直接下载编译好的二进制文

件使用,甚至能够直接在 Docker 容器中运行。

  • 前两种方式是传统方式,适合本地环境下安装使用;最后一种方式则不破坏系统环境,更适

合云计算场景。

安装步骤:

  • 安装python3并设置python3为默认python
1
2
3
apt install python3 
rm -rf
ln -s /usr/bin//python3 /usr/bin/python

可以通过python版本,必须是3.0以上的版本

1
2
3
4
5
python
Python 3.6.9 (default, Oct 8 2020, 12:12:24)
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
  • 安装pip3

  • 使用pip安装docker-compose

1
sudo pip3 install -U docker-compose

这里如果有报错请点击下面

报错内容Command python setup.py egg_info failed with error code 1 in /tmp/pip-build-gl5x6y_i/cryptography/,执行sudo pip3 install --upgrade pip 可解决。

  • 可以看到类似如下输出,说明安装成功。
1
2
3
...
Successfully built dockerpty docopt pyrsistent
Installing collected packages: pycparser, cffi, zipp, websocket-client, typing-extensions, requests, cryptography, bcrypt, pyrsistent, paramiko, importlib-metadata, docker, attrs, texttable, python-dotenv, jsonschema, docopt, dockerpty, distro, cached-property, docker-compose

卸载docker-compose

1
sudo pip3 uninstall docker-compose