| 1 |
# docker compose up |
| 2 |
|
| 3 |
<!---MARKER_GEN_START--> |
| 4 |
Builds, (re)creates, starts, and attaches to containers for a service. |
| 5 |
|
| 6 |
Unless they are already running, this command also starts any linked services. |
| 7 |
|
| 8 |
The `docker compose up` command aggregates the output of each container (like `docker compose logs --follow` does). |
| 9 |
One can optionally select a subset of services to attach to using `--attach` flag, or exclude some services using |
| 10 |
`--no-attach` to prevent output to be flooded by some verbose services. |
| 11 |
|
| 12 |
When the command exits, all containers are stopped. Running `docker compose up --detach` starts the containers in the |
| 13 |
background and leaves them running. |
| 14 |
|
| 15 |
If there are existing containers for a service, and the service’s configuration or image was changed after the |
| 16 |
container’s creation, `docker compose up` picks up the changes by stopping and recreating the containers |
| 17 |
(preserving mounted volumes). To prevent Compose from picking up changes, use the `--no-recreate` flag. |
| 18 |
|
| 19 |
If you want to force Compose to stop and recreate all containers, use the `--force-recreate` flag. |
| 20 |
|
| 21 |
If the process encounters an error, the exit code for this command is `1`. |
| 22 |
If the process is interrupted using `SIGINT` (ctrl + C) or `SIGTERM`, the containers are stopped, and the exit code is `0`. |
| 23 |
|
| 24 |
### Options |
| 25 |
|
| 26 |
| Name | Type | Default | Description | |
| 27 |
|:-------------------------------|:--------------|:---------|:----------------------------------------------------------------------------------------------------------------------------------------------------| |
| 28 |
| `--abort-on-container-exit` | `bool` | | Stops all containers if any container was stopped. Incompatible with -d | |
| 29 |
| `--abort-on-container-failure` | `bool` | | Stops all containers if any container exited with failure. Incompatible with -d | |
| 30 |
| `--always-recreate-deps` | `bool` | | Recreate dependent containers. Incompatible with --no-recreate. | |
| 31 |
| `--attach` | `stringArray` | | Restrict attaching to the specified services. Incompatible with --attach-dependencies. | |
| 32 |
| `--attach-dependencies` | `bool` | | Automatically attach to log output of dependent services | |
| 33 |
| `--build` | `bool` | | Build images before starting containers | |
| 34 |
| `-d`, `--detach` | `bool` | | Detached mode: Run containers in the background | |
| 35 |
| `--dry-run` | `bool` | | Execute command in dry run mode | |
| 36 |
| `--exit-code-from` | `string` | | Return the exit code of the selected service container. Implies --abort-on-container-exit | |
| 37 |
| `--force-recreate` | `bool` | | Recreate containers even if their configuration and image haven't changed | |
| 38 |
| `--menu` | `bool` | | Enable interactive shortcuts when running attached. Incompatible with --detach. Can also be enable/disable by setting COMPOSE_MENU environment var. | |
| 39 |
| `--no-attach` | `stringArray` | | Do not attach (stream logs) to the specified services | |
| 40 |
| `--no-build` | `bool` | | Don't build an image, even if it's policy | |
| 41 |
| `--no-color` | `bool` | | Produce monochrome output | |
| 42 |
| `--no-deps` | `bool` | | Don't start linked services | |
| 43 |
| `--no-log-prefix` | `bool` | | Don't print prefix in logs | |
| 44 |
| `--no-recreate` | `bool` | | If containers already exist, don't recreate them. Incompatible with --force-recreate. | |
| 45 |
| `--no-start` | `bool` | | Don't start the services after creating them | |
| 46 |
| `--pull` | `string` | `policy` | Pull image before running ("always"\|"missing"\|"never") | |
| 47 |
| `--quiet-build` | `bool` | | Suppress the build output | |
| 48 |
| `--quiet-pull` | `bool` | | Pull without printing progress information | |
| 49 |
| `--remove-orphans` | `bool` | | Remove containers for services not defined in the Compose file | |
| 50 |
| `-V`, `--renew-anon-volumes` | `bool` | | Recreate anonymous volumes instead of retrieving data from the previous containers | |
| 51 |
| `--scale` | `stringArray` | | Scale SERVICE to NUM instances. Overrides the `scale` setting in the Compose file if present. | |
| 52 |
| `-t`, `--timeout` | `int` | `0` | Use this timeout in seconds for container shutdown when attached or when containers are already running | |
| 53 |
| `--timestamps` | `bool` | | Show timestamps | |
| 54 |
| `--wait` | `bool` | | Wait for services to be running\|healthy. Implies detached mode. | |
| 55 |
| `--wait-timeout` | `int` | `0` | Maximum duration in seconds to wait for the project to be running\|healthy | |
| 56 |
| `-w`, `--watch` | `bool` | | Watch source code and rebuild/refresh containers when files are updated. | |
| 57 |
| `-y`, `--yes` | `bool` | | Assume "yes" as answer to all prompts and run non-interactively | |
| 58 |
|
| 59 |
|
| 60 |
<!---MARKER_GEN_END--> |
| 61 |
|
| 62 |
## Description |
| 63 |
|
| 64 |
Builds, (re)creates, starts, and attaches to containers for a service. |
| 65 |
|
| 66 |
Unless they are already running, this command also starts any linked services. |
| 67 |
|
| 68 |
The `docker compose up` command aggregates the output of each container (like `docker compose logs --follow` does). |
| 69 |
One can optionally select a subset of services to attach to using `--attach` flag, or exclude some services using |
| 70 |
`--no-attach` to prevent output to be flooded by some verbose services. |
| 71 |
|
| 72 |
When the command exits, all containers are stopped. Running `docker compose up --detach` starts the containers in the |
| 73 |
background and leaves them running. |
| 74 |
|
| 75 |
If there are existing containers for a service, and the service’s configuration or image was changed after the |
| 76 |
container’s creation, `docker compose up` picks up the changes by stopping and recreating the containers |
| 77 |
(preserving mounted volumes). To prevent Compose from picking up changes, use the `--no-recreate` flag. |
| 78 |
|
| 79 |
If you want to force Compose to stop and recreate all containers, use the `--force-recreate` flag. |
| 80 |
|
| 81 |
If the process encounters an error, the exit code for this command is `1`. |
| 82 |
If the process is interrupted using `SIGINT` (ctrl + C) or `SIGTERM`, the containers are stopped, and the exit code is `0`. |