2019-11-05 23:35:43 +08:00
|
|
|
|
# 安装与卸载
|
2015-05-08 20:10:01 +08:00
|
|
|
|
|
2017-11-30 22:38:35 +08:00
|
|
|
|
`Compose` 支持 Linux、macOS、Windows 10 三大平台。
|
2016-12-20 15:35:52 +08:00
|
|
|
|
|
2017-11-30 22:38:35 +08:00
|
|
|
|
`Compose` 可以通过 Python 的包管理工具 `pip` 进行安装,也可以直接下载编译好的二进制文件使用,甚至能够直接在 Docker 容器中运行。
|
2016-12-20 15:35:52 +08:00
|
|
|
|
|
2019-09-01 15:03:32 +08:00
|
|
|
|
`Docker Desktop for Mac/Windows` 自带 `docker-compose` 二进制文件,安装 Docker 之后可以直接使用。
|
2017-11-23 15:48:52 +08:00
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
$ docker-compose --version
|
|
|
|
|
|
2020-12-20 22:18:08 +08:00
|
|
|
|
docker-compose version 1.27.4, build 40524192
|
2017-11-23 15:48:52 +08:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
Linux 系统请使用以下介绍的方法安装。
|
|
|
|
|
|
2019-11-05 23:35:43 +08:00
|
|
|
|
## 二进制包
|
2017-11-23 15:48:52 +08:00
|
|
|
|
|
2017-11-30 22:38:35 +08:00
|
|
|
|
在 Linux 上的也安装十分简单,从 [官方 GitHub Release](https://github.com/docker/compose/releases) 处直接下载编译好的二进制文件即可。
|
2017-11-23 15:48:52 +08:00
|
|
|
|
|
2017-11-30 22:38:35 +08:00
|
|
|
|
例如,在 Linux 64 位系统上直接下载对应的二进制包。
|
2017-11-23 15:48:52 +08:00
|
|
|
|
|
|
|
|
|
```bash
|
2020-12-20 22:18:08 +08:00
|
|
|
|
$ sudo curl -L https://github.com/docker/compose/releases/download/1.27.4/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
|
|
|
|
|
|
|
|
|
|
# 国内用户可以使用以下方式加快下载
|
|
|
|
|
$ sudo curl -L https://download.fastgit.org/docker/compose/releases/download/1.27.4/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
|
2019-09-01 14:46:33 +08:00
|
|
|
|
|
2017-11-30 22:38:35 +08:00
|
|
|
|
$ sudo chmod +x /usr/local/bin/docker-compose
|
2017-11-23 15:48:52 +08:00
|
|
|
|
```
|
|
|
|
|
|
2019-11-05 23:35:43 +08:00
|
|
|
|
## PIP 安装
|
2017-11-23 15:48:52 +08:00
|
|
|
|
|
2017-11-30 22:38:35 +08:00
|
|
|
|
*注:* `x86_64` 架构的 Linux 建议按照上边的方法下载二进制包进行安装,如果您计算机的架构是 `ARM` (例如,树莓派),再使用 `pip` 安装。
|
2017-11-23 15:48:52 +08:00
|
|
|
|
|
2016-12-20 15:35:52 +08:00
|
|
|
|
这种方式是将 Compose 当作一个 Python 应用来从 pip 源中安装。
|
|
|
|
|
|
|
|
|
|
执行安装命令:
|
2015-05-08 20:10:01 +08:00
|
|
|
|
|
2017-11-22 11:13:23 +08:00
|
|
|
|
```bash
|
2015-05-08 20:10:01 +08:00
|
|
|
|
$ sudo pip install -U docker-compose
|
|
|
|
|
```
|
|
|
|
|
|
2016-12-20 15:35:52 +08:00
|
|
|
|
可以看到类似如下输出,说明安装成功。
|
2017-11-23 15:48:52 +08:00
|
|
|
|
|
2017-11-22 11:13:23 +08:00
|
|
|
|
```bash
|
2016-12-20 15:35:52 +08:00
|
|
|
|
Collecting docker-compose
|
2020-12-20 22:18:08 +08:00
|
|
|
|
Downloading docker-compose-1.27.4.tar.gz (149kB): 149kB downloaded
|
2016-12-20 15:35:52 +08:00
|
|
|
|
...
|
|
|
|
|
Successfully installed docker-compose cached-property requests texttable websocket-client docker-py dockerpty six enum34 backports.ssl-match-hostname ipaddress
|
|
|
|
|
```
|
|
|
|
|
|
2019-11-05 23:35:43 +08:00
|
|
|
|
## bash 补全命令
|
2015-05-08 20:10:01 +08:00
|
|
|
|
|
2017-11-22 11:13:23 +08:00
|
|
|
|
```bash
|
2020-12-20 22:18:08 +08:00
|
|
|
|
$ curl -L https://raw.githubusercontent.com/docker/compose/1.27.4/contrib/completion/bash/docker-compose > /etc/bash_completion.d/docker-compose
|
2016-12-20 15:35:52 +08:00
|
|
|
|
```
|
|
|
|
|
|
2019-11-05 23:35:43 +08:00
|
|
|
|
## 卸载
|
2017-11-23 15:48:52 +08:00
|
|
|
|
|
2016-12-20 15:35:52 +08:00
|
|
|
|
如果是二进制包方式安装的,删除二进制文件即可。
|
|
|
|
|
|
2017-11-22 11:13:23 +08:00
|
|
|
|
```bash
|
2016-12-20 15:35:52 +08:00
|
|
|
|
$ sudo rm /usr/local/bin/docker-compose
|
|
|
|
|
```
|
|
|
|
|
|
2017-11-26 09:54:04 +08:00
|
|
|
|
如果是通过 `pip` 安装的,则执行如下命令即可删除。
|
2015-05-08 20:10:01 +08:00
|
|
|
|
|
2017-11-22 11:13:23 +08:00
|
|
|
|
```bash
|
2016-12-20 15:35:52 +08:00
|
|
|
|
$ sudo pip uninstall docker-compose
|
2017-11-01 00:20:30 +08:00
|
|
|
|
```
|