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: build [options] [SERVICE...]
Options:
Usage: config [options]
爲服務建立容器.只是單純的create,還須要使用start啓動compose
Usage: create [options] [SERVICE...]
--build 建立容器前,生成鏡像.
Usage: down [options]
attached to containers.
--remove-orphans Remove containers for services not defined in the
Usage: exec [options] SERVICE COMMAND [ARGS...]
Options:
-d 分離模式,後臺運行命令.
--privileged 獲取特權.
--user USER 指定運行的用戶.
-T 禁用分配TTY. By default `docker-compose exec`
docker-compose exec web sh
Usage: unpause [SERVICE...]
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: pull [options] [SERVICE...]
Usage: rm [options] [SERVICE...]
Options:
-a, --all Also remove one-off containers created by
By default, anonymous volumes attached to containers will not be removed. You can override this with -v
. To list all volumes, use Docker volume ls
.python
Usage: run [options] [-e KEY=VAL...] SERVICE [COMMAND] [ARGS...]
T 禁用TTY.
啓動web服務器,並執行bash命令.web
$ docker-compose run web bash
$ 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
$ docker-compose run db psql -h db -U docker
不linke容器,單獨啓動指定容器:sql
$ docker-compose run --no-deps web python manage.py shell
Usage: up [options] [SERVICE...]
Options:
-d 後臺運行,輸出容器的名字.
Incompatible with --abort-on-container-exit.
--no-deps 不啓動link服務.
Incompatible with --no-recreate.
Incompatible with --force-recreate.
--abort-on-container-exit 任何容器中止,自動中止全部容器.