2015-07-17 02:30:49 +02:00
|
|
|
<!--[metadata]>
|
|
|
|
+++
|
2016-02-01 18:10:21 +01:00
|
|
|
title = "Overview of docker-compose CLI"
|
|
|
|
description = "Overview of docker-compose CLI"
|
2015-07-17 02:30:49 +02:00
|
|
|
keywords = ["fig, composition, compose, docker, orchestration, cli, docker-compose"]
|
2016-02-01 18:10:21 +01:00
|
|
|
aliases = ["/compose/reference/docker-compose/"]
|
2015-07-17 02:30:49 +02:00
|
|
|
[menu.main]
|
|
|
|
parent = "smn_compose_cli"
|
2015-08-24 21:25:25 +02:00
|
|
|
weight=-2
|
2015-07-17 02:30:49 +02:00
|
|
|
+++
|
|
|
|
<![end-metadata]-->
|
|
|
|
|
|
|
|
|
2016-02-01 18:10:21 +01:00
|
|
|
# Overview of docker-compose CLI
|
2015-07-17 02:30:49 +02:00
|
|
|
|
2016-01-29 01:17:18 +01:00
|
|
|
This page provides the usage information for the `docker-compose` Command.
|
|
|
|
You can also see this information by running `docker-compose --help` from the
|
|
|
|
command line.
|
|
|
|
|
2015-07-17 02:30:49 +02:00
|
|
|
```
|
2016-01-29 01:17:18 +01:00
|
|
|
Define and run multi-container applications with Docker.
|
|
|
|
|
2015-07-17 02:30:49 +02:00
|
|
|
Usage:
|
2015-09-16 21:03:55 +02:00
|
|
|
docker-compose [-f=<arg>...] [options] [COMMAND] [ARGS...]
|
2015-07-17 02:30:49 +02:00
|
|
|
docker-compose -h|--help
|
|
|
|
|
|
|
|
Options:
|
2016-03-24 15:41:51 +01:00
|
|
|
-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)
|
2015-07-17 02:30:49 +02:00
|
|
|
|
|
|
|
Commands:
|
|
|
|
build Build or rebuild services
|
2016-01-29 01:17:18 +01:00
|
|
|
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
|
2015-07-17 02:30:49 +02:00
|
|
|
help Get help on a command
|
|
|
|
kill Kill containers
|
|
|
|
logs View output from containers
|
2015-07-25 22:20:58 +02:00
|
|
|
pause Pause services
|
2015-07-17 02:30:49 +02:00
|
|
|
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
|
2015-07-25 22:20:58 +02:00
|
|
|
unpause Unpause services
|
2015-07-17 02:30:49 +02:00
|
|
|
up Create and start containers
|
2015-09-16 21:03:55 +02:00
|
|
|
version Show the Docker-Compose version information
|
2016-01-29 01:17:18 +01:00
|
|
|
|
2015-07-17 02:30:49 +02:00
|
|
|
```
|
|
|
|
|
2015-09-16 21:03:55 +02:00
|
|
|
The Docker Compose binary. You use this command to build and manage multiple
|
|
|
|
services in Docker containers.
|
2015-07-17 02:30:49 +02:00
|
|
|
|
2015-09-16 21:03:55 +02:00
|
|
|
Use the `-f` flag to specify the location of a Compose configuration file. You
|
|
|
|
can supply multiple `-f` configuration files. When you supply multiple files,
|
|
|
|
Compose combines them into a single configuration. Compose builds the
|
|
|
|
configuration in the order you supply the files. Subsequent files override and
|
|
|
|
add to their successors.
|
2015-07-17 02:30:49 +02:00
|
|
|
|
2015-09-16 21:03:55 +02:00
|
|
|
For example, consider this command line:
|
|
|
|
|
|
|
|
```
|
|
|
|
$ docker-compose -f docker-compose.yml -f docker-compose.admin.yml run backup_db`
|
|
|
|
```
|
|
|
|
|
|
|
|
The `docker-compose.yml` file might specify a `webapp` service.
|
|
|
|
|
|
|
|
```
|
|
|
|
webapp:
|
|
|
|
image: examples/web
|
|
|
|
ports:
|
|
|
|
- "8000:8000"
|
|
|
|
volumes:
|
|
|
|
- "/data"
|
|
|
|
```
|
|
|
|
|
|
|
|
If the `docker-compose.admin.yml` also specifies this same service, any matching
|
|
|
|
fields will override the previous file. New values, add to the `webapp` service
|
|
|
|
configuration.
|
|
|
|
|
|
|
|
```
|
|
|
|
webapp:
|
|
|
|
build: .
|
|
|
|
environment:
|
|
|
|
- DEBUG=1
|
|
|
|
```
|
|
|
|
|
|
|
|
Use a `-f` with `-` (dash) as the filename to read the configuration from
|
|
|
|
stdin. When stdin is used all paths in the configuration are
|
|
|
|
relative to the current working directory.
|
|
|
|
|
|
|
|
The `-f` flag is optional. If you don't provide this flag on the command line,
|
2016-01-25 19:04:03 +01:00
|
|
|
Compose traverses the working directory and its parent directories looking for a
|
2015-10-28 17:27:14 +01:00
|
|
|
`docker-compose.yml` and a `docker-compose.override.yml` file. You must
|
2016-01-27 00:22:21 +01:00
|
|
|
supply at least the `docker-compose.yml` file. If both files are present on the
|
|
|
|
same directory level, Compose combines the two files into a single configuration.
|
|
|
|
The configuration in the `docker-compose.override.yml` file is applied over and
|
2016-01-25 19:04:03 +01:00
|
|
|
in addition to the values in the `docker-compose.yml` file.
|
2015-10-28 17:27:14 +01:00
|
|
|
|
2016-01-29 01:17:18 +01:00
|
|
|
See also the `COMPOSE_FILE` [environment variable](envvars.md#compose-file).
|
2015-09-16 21:03:55 +02:00
|
|
|
|
|
|
|
Each configuration has a project name. If you supply a `-p` flag, you can
|
|
|
|
specify a project name. If you don't specify the flag, Compose uses the current
|
2015-10-28 17:27:14 +01:00
|
|
|
directory name. See also the `COMPOSE_PROJECT_NAME` [environment variable](
|
2016-01-29 01:17:18 +01:00
|
|
|
envvars.md#compose-project-name)
|
2015-07-17 02:30:49 +02:00
|
|
|
|
2015-09-02 22:59:04 +02:00
|
|
|
|
|
|
|
## Where to go next
|
|
|
|
|
2016-01-29 01:17:18 +01:00
|
|
|
* [CLI environment variables](envvars.md)
|