...
1# stack config
2
3<!---MARKER_GEN_START-->
4Outputs the final config file, after doing merges and interpolations
5
6### Options
7
8| Name | Type | Default | Description |
9|:-----------------------|:--------------|:--------|:--------------------------------------------------|
10| `-c`, `--compose-file` | `stringSlice` | | Path to a Compose file, or `-` to read from stdin |
11| `--skip-interpolation` | | | Skip interpolation and output only merged config |
12
13
14<!---MARKER_GEN_END-->
15
16## Description
17
18Outputs the final Compose file, after doing the merges and interpolations of the input Compose files.
19
20## Examples
21
22The following command outputs the result of the merge and interpolation of two Compose files.
23
24```console
25$ docker stack config --compose-file docker-compose.yml --compose-file docker-compose.prod.yml
26```
27
28The Compose file can also be provided as standard input with `--compose-file -`:
29
30```console
31$ cat docker-compose.yml | docker stack config --compose-file -
32```
33
34### Skipping interpolation
35
36In some cases, it might be useful to skip interpolation of environment variables.
37For example, when you want to pipe the output of this command back to `stack deploy`.
38
39If you have a regex for a redirect route in an environment variable for your webserver you would use two `$` signs to prevent `stack deploy` from interpolating `${1}`.
40
41```yaml
42 service: webserver
43 environment:
44 REDIRECT_REGEX=http://host/redirect/$${1}
45```
46
47With interpolation, the `stack config` command will replace the environment variable in the Compose file
48with `REDIRECT_REGEX=http://host/redirect/${1}`, but then when piping it back to the `stack deploy`
49command it will be interpolated again and result in undefined behavior.
50That is why, when piping the output back to `stack deploy` one should always prefer the `--skip-interpolation` option.
51
52```console
53$ docker stack config --compose-file web.yml --compose-file web.prod.yml --skip-interpolation | docker stack deploy --compose-file -
54```
55
56## Related commands
57
58* [stack deploy](stack_deploy.md)
59* [stack ps](stack_ps.md)
60* [stack rm](stack_rm.md)
61* [stack services](stack_services.md)
View as plain text