Total Pageviews

Sunday 25 September 2016

如何安装 docker-compose

wget https://github.com/docker/compose/releases/download/1.8.1/docker-compose-Linux-x86_64
cp docker-compose-Linux-x86_64 /usr/local/bin/docker-compose


发布的二进制包可以在 https://github.com/docker/compose/releases 找到。

下载后直接放到执行路径即可。


root@shc:~# docker-compose version
docker-compose version 1.8.1, build 878cff1
docker-py version: 1.10.3
CPython version: 2.7.9
OpenSSL version: OpenSSL 1.0.1e 11 Feb 2013
root@shc:~# 

项目地址:https://github.com/docker/compose/

使用方法:
克隆某个含有docker-compose.yml文件的仓库,进入该仓库,运行:
docker-compose build 或
docker-compose up --build 或
docker-compose up -d

To build the image you must use `docker-compose build` or `docker-compose up --build`.
----------------------
另一种安装方法:用PIP安装。

执行命令:
$ sudo pip install -U docker-compose
安装成功后,可以查看 docker-compose 命令的用法。
$ docker-compose -h
Fast, isolated development environments using Docker.

Usage:
  docker-compose [options] [COMMAND] [ARGS...]
  docker-compose -h|--help

Options:
  --verbose                 Show more output
  --version                 Print version and exit
  -f, --file FILE           Specify an alternate compose file (default: docker-compose.yml)
  -p, --project-name NAME   Specify an alternate project name (default: directory name)

Commands:
  build     Build or rebuild services
  help      Get help on a command
  kill      Kill containers
  logs      View output from containers
  port      Print the public port for a port binding
  ps        List containers
  pull      Pulls service images
  rm        Remove stopped containers
  run       Run a one-off command
  scale     Set number of containers for a service
  start     Start services
  stop      Stop services
  restart   Restart services
  up        Create and start containers
from https://yeasy.gitbooks.io/docker_practice/content/compose/install.html,
https://yeasy.gitbooks.io/docker_practice/content/compose/usage.html
https://yeasy.gitbooks.io/docker_practice/content/compose/commands.html
https://yeasy.gitbooks.io/docker_practice/content/compose/yaml_file.html
----------
Docker是一个开源的引擎,可以轻松的为任何应用创建一个轻量级的、
可移植的、自给自足的容器。 
Docker Compose是在使用Docker容器部署分布式应用时的工具,
可以定义哪个容器运行哪个应用。
使用Compose,你只需定义一个多容器应用的yml文件,
然后使用一条命令即可部署运行所有容器。 
安装Docker Compose
使用以下命令:curl -L https://github.com/docker/compose/releases/download/1.17.0/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
#验证是否安装成功
docker-compose --version
#返回以下信息即安装成功
docker-compose version 1.17.0, build 1719ceb
更多介绍及使用请看:https://docs.docker.com