Compose是一个定义和运行multi-container Docker应用的一个工具。使用Compose可以通过一个Compose file配置应用的services。使用一个命令就可以创建和运行所有的服务。
使用Compose:
- 用
Dockerfile定义app的环境,可以运行在任何地方 - 用
Docker-compose.yml定义服务,可以在一个分离的环境中一起运行 - 运行
docker-compose up,Compose将会启动并运行整个app
安装
- On Linux, you can download the Docker Compose binary from the Compose repository release page on GitHub.
replacing$dockerComposeVersionwith the specific version of Compose you want to use
curl -L https://github.com/docker/compose/releases/download/$dockerComposeVersion/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
- Apply executable permissions to the binary
sudo chmod +x /usr/local/bin/docker-compose
- Test the installation
docker-compose --version