Docker Compose 安装
目录
- 参考资料
- 什么是 Docker Compose ?
- 依赖
- 安装
- 1. 下载 Docker Compose
- 2. 添加执行权限
- 3. 软链到 /usr/bin
- 4. 测试
- 卸载 Docker Compose
- 安装 Docker Compose 命令补全工具
- 1. 切换到 /etc/bash_completion.d/
- 2. curl 下载
- 3. 重新加载终端
参考资料
- Docker Compose官方文档:https://docs.docker.com/compose/
- Docker Compose 安装说明:https://docs.docker.com/compose/install/
什么是 Docker Compose ?
Compose is a tool for defining and running multi-container Docker applications.With Compose, you use a YAML file to configure your application’s services. Then, with a single command, you create and start all the services from your configuration.
Compose一个工具用于定义和运行多容器 Docker 应用.它能够使用 YAML 文件定义配置应用服务,然后一个简单命令就可以创建和启动所有服务.
依赖
必须安装 Docker Engine 然后再安装 Docker Compose.
安装
1. 下载 Docker Compose
curl 下载 并放到 /usr/local/bin/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
或者从 https://github.com/docker/compose/releases 直接下载然后解压放到 /usr/local/bin/
2. 添加执行权限
sudo chmod +x /usr/local/bin/docker-compose
3. 软链到 /usr/bin
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
4. 测试
docker-compose --version
卸载 Docker Compose
- 如果是 curl 安装
sudo rm /usr/local/bin/docker-compose
- 如果是 pip 安装
pip uninstall docker-compose
安装 Docker Compose 命令补全工具
1. 切换到 /etc/bash_completion.d/
2. curl 下载
sudo curl \
-L https://raw.githubusercontent.com/docker/compose/1.29.2/contrib/completion/bash/docker-compose \
-o /etc/bash_completion.d/docker-compose
3. 重新加载终端
- 要么,关闭当前终端窗口,然后打开一个新的终端
- 要么 执行
source ~/.bashrc
命令