上一篇:Docker的那些事儿—什么是docker compose?
安装docker-compose
前提:已安装Docker
对于Mac和Windows,Docker Toolbox已经包含了Compose,因此不需要额外安装。对于Linux环境,官网也提供了两种方便的安装方式:
1、二进制安装(推荐)
2、PIP安装
二进制安装
1、curl下载最新版二进制文件
curl -L https://github.com/docker/compose/releases/download/1.19.0/docker-compose-`uname-s`-`uname -m` -o /usr/local/bin/docker-compose
Compose项目目前是在GitHub上进行维护的,目前最新稳定版本是1.19.0。
地址:https://github.com/docker/compose/releases
2、增加可执行权限
chmod +x /usr/local/bin/docker-compose
3、(可选)添加bash自动补全命令
curl -L https://raw.githubusercontent.com/docker/compose/1.19.0/contrib/completion/bash/docker-compose -o /etc/bash_completion.d/docker-compose
可以参考:https://docs.docker.com/compose/completion/
4、测试安装是否成功
docker-compose version
root@Ubuntu-001:~# docker-compose version
docker-compose version1.19.0, build 9e633ef
docker-py version: 2.7.0
CPython version: 2.7.13
OpenSSL version: OpenSSL1.0.1t 3 May 2016
PIP安装(已安装pip)
pip install docker-compose
安装完Compose,查询docker-compose命令
root@Ubuntu-001:~# docker-compose--help
Define and run multi-container applications with Docker
Usage:
docker-compose [-f ...] [options][COMMAND] [ARGS...]
docker-compose -h|--help
Options:
-f, --file FILE Specify an alternate compose file(default: docker-compose.yml)
-p, --project-name NAME Specify an alternate project name(default: directory name)
--verbose Show more output
--no-ansi Do not print ANSI control characters
-v, --version Print version and exit
-H, --host HOST Daemon socket to connect to
--tls Use TLS; implied by--tlsverify
--tlscacert CA_PATH Trust certs signed only by this CA
--tlscert CLIENT_CERT_PATH Path to TLS certificate file
--tlskey TLS_KEY_PATH Path to TLS key file
--tlsverify Use TLS and verify the remote
--skip-hostname-check Don't check the daemon's hostname against the name specified
in the clientcertificate (for example if your docker host
is an IP address)
--project-directory PATH Specify an alternate working directory
(default: thepath of the Compose file)
Commands:
build Build or rebuild services
bundle Generate a Docker bundle from the Compose file
config Validate and view the Compose file
create Create services
down Stop and remove containers, networks, images, and volumes
events Receive real time events from containers
exec Execute a command in a running container
help Get help on a command
images List images
kill Kill containers
logs View output from containers
pause Pause services
port Print the public port for a port binding
ps List containers
pull Pull service images
push Push service images
restart Restart services
rm Remove stopped containers
run Run a one-off command
scale Set number of containers for a service
start Start services
stop Stop services
top Display the running processes
unpause Unpause services
up Create and start containers
version Show the Docker-Compose version information
卸载docker-compose
1、如果你使用二进制安装的
rm /usr/local/bin/docker-compose
2、如果你通过PIP安装的
pip uninstall docker-compose
下一篇:Docker的那些事儿—一个例子教你docker compose是如何使用的(一)?