Define and run multi-container applications with Docker.
Usage:
docker-compose [-f=<arg>...] [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
-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 client certificate (for example if your docker host
is an IP address)
Commands:
build Build or rebuild services
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
help Get help on a command
kill Kill containers
logs View output from containers
pause Pause services
port Print the public port for a port binding
ps List containers
pull Pulls 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
unpause Unpause services
up Create and start containers
version Show the Docker-Compose version information
Usage: port [options] SERVICE PRIVATE_PORT
Options:
--protocol=proto tcp or udp [default: tcp]
--index=index index of the container if there are multiple
instances of a service [default: 1]
Usage: restart [options] [SERVICE...]
Options:
-t, --timeout TIMEOUT Specify a shutdown timeout in seconds. (default: 10)
Restarts services.
rm
Usage: rm [options] [SERVICE...]
Options:
--force Don't ask to confirm removal
-v 期初加载到容器的任何匿名卷
-a, --all Also remove one-off containers created by
docker-compose run
Removes stopped service containers. 如果服务在运行,需要先docker-compose stop 停止容器 By default, anonymous volumes attached to containers will not be removed. You can override this with Docker
volume ls.
Any data which is not in a volume will be lost.
run
Usage: run [options] [-e KEY=VAL...] SERVICE [COMMAND] [ARGS...]
.
-e KEY=VAL 设置环境变量参数,可以使用多次
--user=""
指定运行的用户
--no-deps
不启动link服务,只启动run的服务.
--rm
运行后删除容器,后台运行模式除外(-d).
p, --publish=[]
开放端口
--service-ports
compose文件中配置什么端口,就映射什么端口.
T 禁用TTY.
--workdir=""
设置工作目录 启动web服务器,并执行bash命令.
$ docker-compose run web bash
根据compose配置文件制定的端口,映射到主机:
$ docker-compose run --service-ports web python manage.py shell
指定端口映射到主机:
$ docker-compose run --publish 8080:80 -p 2022:22 -p 127.0.0.1:2021:21 web python manage.py shell
link db容器:
$ docker-compose run db psql -h db -U docker
不linke容器,单独启动指定容器:
$ docker-compose run --no-deps web python manage.py shell
scale
Usage: scale [SERVICE=NUM...]
设置服务的个数.
$ docker-compose scale web=2 worker=3
start
Usage: start [SERVICE...]
启动服务.
stop
Usage: stop [options] [SERVICE...]
Options:
default: 10).
停止容器.
up
Usage: up [options] [SERVICE...]
Options:
-d 后台运行,输出容器的名字.
Incompatible with --abort-on-container-exit.