在 Linux 系统上安装 Compose

Docker Compose 依赖 Docker Engine 进行任何有意义的工作,因此请确保根据您的设置,在本地或远程安装了 Docker Engine。

Install using pip

For alpine, the following dependency packages are needed: py-pip, python3-dev, libffi-dev, openssl-dev, gcc, libc-dev, rust, cargo, and make.

Compose can be installed from pypi using pip. If you install using pip, we recommend that you use a virtualenv because many operating systems have python system packages that conflict with docker-compose dependencies. See the virtualenv tutorial to get started.

1
pip3 install docker-compose

运行此命令以下载 Docker Compose 的当前稳定版本:

1
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

对二进制文件应用可执行权限:

1
sudo chmod +x /usr/local/bin/docker-compose

注意:如果docker-compose安装后命令失败,请检查您的路径。您还可以/usr/bin在路径中创建指向或任何其他目录的符号链接。

例如:

1
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose

测试安装

1
docker-compose --version

shell

1
2
3
4
5
6
7
8
9
10
## 运行此命令以下载 Docker Compose 的当前稳定版本:
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

## 对二进制文件应用可执行权限:
sudo chmod +x /usr/local/bin/docker-compose

sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
## 测试安装
docker-compose --version

参考文章

评论