File: docker_compose.yaml

package info (click to toggle)
docker-compose 2.32.4-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,300 kB
  • sloc: makefile: 113; sh: 2
file content (378 lines) | stat: -rw-r--r-- 15,482 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
command: docker compose
short: Docker Compose
long: Define and run multi-container applications with Docker
usage: docker compose
pname: docker
plink: docker.yaml
cname:
    - docker compose attach
    - docker compose build
    - docker compose commit
    - docker compose config
    - docker compose cp
    - docker compose create
    - docker compose down
    - docker compose events
    - docker compose exec
    - docker compose export
    - docker compose images
    - docker compose kill
    - docker compose logs
    - docker compose ls
    - docker compose pause
    - docker compose port
    - docker compose ps
    - docker compose pull
    - docker compose push
    - docker compose restart
    - docker compose rm
    - docker compose run
    - docker compose scale
    - docker compose start
    - docker compose stats
    - docker compose stop
    - docker compose top
    - docker compose unpause
    - docker compose up
    - docker compose version
    - docker compose wait
    - docker compose watch
clink:
    - docker_compose_attach.yaml
    - docker_compose_build.yaml
    - docker_compose_commit.yaml
    - docker_compose_config.yaml
    - docker_compose_cp.yaml
    - docker_compose_create.yaml
    - docker_compose_down.yaml
    - docker_compose_events.yaml
    - docker_compose_exec.yaml
    - docker_compose_export.yaml
    - docker_compose_images.yaml
    - docker_compose_kill.yaml
    - docker_compose_logs.yaml
    - docker_compose_ls.yaml
    - docker_compose_pause.yaml
    - docker_compose_port.yaml
    - docker_compose_ps.yaml
    - docker_compose_pull.yaml
    - docker_compose_push.yaml
    - docker_compose_restart.yaml
    - docker_compose_rm.yaml
    - docker_compose_run.yaml
    - docker_compose_scale.yaml
    - docker_compose_start.yaml
    - docker_compose_stats.yaml
    - docker_compose_stop.yaml
    - docker_compose_top.yaml
    - docker_compose_unpause.yaml
    - docker_compose_up.yaml
    - docker_compose_version.yaml
    - docker_compose_wait.yaml
    - docker_compose_watch.yaml
options:
    - option: all-resources
      value_type: bool
      default_value: "false"
      description: Include all resources, even those not used by services
      deprecated: false
      hidden: false
      experimental: false
      experimentalcli: false
      kubernetes: false
      swarm: false
    - option: ansi
      value_type: string
      default_value: auto
      description: |
        Control when to print ANSI control characters ("never"|"always"|"auto")
      deprecated: false
      hidden: false
      experimental: false
      experimentalcli: false
      kubernetes: false
      swarm: false
    - option: compatibility
      value_type: bool
      default_value: "false"
      description: Run compose in backward compatibility mode
      deprecated: false
      hidden: false
      experimental: false
      experimentalcli: false
      kubernetes: false
      swarm: false
    - option: dry-run
      value_type: bool
      default_value: "false"
      description: Execute command in dry run mode
      deprecated: false
      hidden: false
      experimental: false
      experimentalcli: false
      kubernetes: false
      swarm: false
    - option: env-file
      value_type: stringArray
      default_value: '[]'
      description: Specify an alternate environment file
      deprecated: false
      hidden: false
      experimental: false
      experimentalcli: false
      kubernetes: false
      swarm: false
    - option: file
      shorthand: f
      value_type: stringArray
      default_value: '[]'
      description: Compose configuration files
      deprecated: false
      hidden: false
      experimental: false
      experimentalcli: false
      kubernetes: false
      swarm: false
    - option: no-ansi
      value_type: bool
      default_value: "false"
      description: Do not print ANSI control characters (DEPRECATED)
      deprecated: false
      hidden: true
      experimental: false
      experimentalcli: false
      kubernetes: false
      swarm: false
    - option: parallel
      value_type: int
      default_value: "-1"
      description: Control max parallelism, -1 for unlimited
      deprecated: false
      hidden: false
      experimental: false
      experimentalcli: false
      kubernetes: false
      swarm: false
    - option: profile
      value_type: stringArray
      default_value: '[]'
      description: Specify a profile to enable
      deprecated: false
      hidden: false
      experimental: false
      experimentalcli: false
      kubernetes: false
      swarm: false
    - option: progress
      value_type: string
      default_value: auto
      description: Set type of progress output (auto, tty, plain, json, quiet)
      deprecated: false
      hidden: false
      experimental: false
      experimentalcli: false
      kubernetes: false
      swarm: false
    - option: project-directory
      value_type: string
      description: |-
        Specify an alternate working directory
        (default: the path of the, first specified, Compose file)
      deprecated: false
      hidden: false
      experimental: false
      experimentalcli: false
      kubernetes: false
      swarm: false
    - option: project-name
      shorthand: p
      value_type: string
      description: Project name
      deprecated: false
      hidden: false
      experimental: false
      experimentalcli: false
      kubernetes: false
      swarm: false
    - option: verbose
      value_type: bool
      default_value: "false"
      description: Show more output
      deprecated: false
      hidden: true
      experimental: false
      experimentalcli: false
      kubernetes: false
      swarm: false
    - option: version
      shorthand: v
      value_type: bool
      default_value: "false"
      description: Show the Docker Compose version information
      deprecated: false
      hidden: true
      experimental: false
      experimentalcli: false
      kubernetes: false
      swarm: false
    - option: workdir
      value_type: string
      description: |-
        DEPRECATED! USE --project-directory INSTEAD.
        Specify an alternate working directory
        (default: the path of the, first specified, Compose file)
      deprecated: false
      hidden: true
      experimental: false
      experimentalcli: false
      kubernetes: false
      swarm: false
examples: |-
    ### Use `-f` to specify the name and path of one or more Compose files
    Use the `-f` flag to specify the location of a Compose configuration file.

    #### Specifying multiple Compose files
    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 predecessors.

    For example, consider this command line:

    ```console
    $ docker compose -f docker-compose.yml -f docker-compose.admin.yml run backup_db
    ```

    The `docker-compose.yml` file might specify a `webapp` service.

    ```yaml
    services:
      webapp:
        image: examples/web
        ports:
          - "8000:8000"
        volumes:
          - "/data"
    ```
    If the `docker-compose.admin.yml` also specifies this same service, any matching fields override the previous file.
    New values, add to the `webapp` service configuration.

    ```yaml
    services:
      webapp:
        build: .
        environment:
          - DEBUG=1
    ```

    When you use multiple Compose files, all paths in the files are relative to the first configuration file specified
    with `-f`. You can use the `--project-directory` option to override this base path.

    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, Compose traverses the working directory
    and its parent directories looking for a `compose.yaml` or `docker-compose.yaml` file.

    #### Specifying a path to a single Compose file
    You can use the `-f` flag to specify a path to a Compose file that is not located in the current directory, either
    from the command line or by setting up a `COMPOSE_FILE` environment variable in your shell or in an environment file.

    For an example of using the `-f` option at the command line, suppose you are running the Compose Rails sample, and
    have a `compose.yaml` file in a directory called `sandbox/rails`. You can use a command like `docker compose pull` to
    get the postgres image for the db service from anywhere by using the `-f` flag as follows:

    ```console
    $ docker compose -f ~/sandbox/rails/compose.yaml pull db
    ```

    ### Use `-p` to specify a project name

    Each configuration has a project name. Compose sets the project name using
    the following mechanisms, in order of precedence:
    - The `-p` command line flag
    - The `COMPOSE_PROJECT_NAME` environment variable
    - The top level `name:` variable from the config file (or the last `name:`
    from a series of config files specified using `-f`)
    - The `basename` of the project directory containing the config file (or
    containing the first config file specified using `-f`)
    - The `basename` of the current directory if no config file is specified
    Project names must contain only lowercase letters, decimal digits, dashes,
    and underscores, and must begin with a lowercase letter or decimal digit. If
    the `basename` of the project directory or current directory violates this
    constraint, you must use one of the other mechanisms.

    ```console
    $ docker compose -p my_project ps -a
    NAME                 SERVICE    STATUS     PORTS
    my_project_demo_1    demo       running

    $ docker compose -p my_project logs
    demo_1  | PING localhost (127.0.0.1): 56 data bytes
    demo_1  | 64 bytes from 127.0.0.1: seq=0 ttl=64 time=0.095 ms
    ```

    ### Use profiles to enable optional services

    Use `--profile` to specify one or more active profiles
    Calling `docker compose --profile frontend up` starts the services with the profile `frontend` and services
    without any specified profiles.
    You can also enable multiple profiles, e.g. with `docker compose --profile frontend --profile debug up` the profiles `frontend` and `debug` is enabled.

    Profiles can also be set by `COMPOSE_PROFILES` environment variable.

    ### Configuring parallelism

    Use `--parallel` to specify the maximum level of parallelism for concurrent engine calls.
    Calling `docker compose --parallel 1 pull` pulls the pullable images defined in the Compose file
    one at a time. This can also be used to control build concurrency.

    Parallelism can also be set by the `COMPOSE_PARALLEL_LIMIT` environment variable.

    ### Set up environment variables

    You can set environment variables for various docker compose options, including the `-f`, `-p` and `--profiles` flags.

    Setting the `COMPOSE_FILE` environment variable is equivalent to passing the `-f` flag,
    `COMPOSE_PROJECT_NAME` environment variable does the same as the `-p` flag,
    `COMPOSE_PROFILES` environment variable is equivalent to the `--profiles` flag
    and `COMPOSE_PARALLEL_LIMIT` does the same as the `--parallel` flag.

    If flags are explicitly set on the command line, the associated environment variable is ignored.

    Setting the `COMPOSE_IGNORE_ORPHANS` environment variable to `true` stops docker compose from detecting orphaned
    containers for the project.

    Setting the `COMPOSE_MENU` environment variable to `false` disables the helper menu when running `docker compose up`
    in attached mode. Alternatively, you can also run `docker compose up --menu=false` to disable the helper menu.

    ### Use Dry Run mode to test your command

    Use `--dry-run` flag to test a command without changing your application stack state.
    Dry Run mode shows you all the steps Compose applies when executing a command, for example:
    ```console
    $ docker compose --dry-run up --build -d
    [+] Pulling 1/1
     ✔ DRY-RUN MODE -  db Pulled                                                                                                                                                                                                               0.9s
    [+] Running 10/8
     ✔ DRY-RUN MODE -    build service backend                                                                                                                                                                                                 0.0s
     ✔ DRY-RUN MODE -  ==> ==> writing image dryRun-754a08ddf8bcb1cf22f310f09206dd783d42f7dd                                                                                                                                                   0.0s
     ✔ DRY-RUN MODE -  ==> ==> naming to nginx-golang-mysql-backend                                                                                                                                                                            0.0s
     ✔ DRY-RUN MODE -  Network nginx-golang-mysql_default                                    Created                                                                                                                                           0.0s
     ✔ DRY-RUN MODE -  Container nginx-golang-mysql-db-1                                     Created                                                                                                                                           0.0s
     ✔ DRY-RUN MODE -  Container nginx-golang-mysql-backend-1                                Created                                                                                                                                           0.0s
     ✔ DRY-RUN MODE -  Container nginx-golang-mysql-proxy-1                                  Created                                                                                                                                           0.0s
     ✔ DRY-RUN MODE -  Container nginx-golang-mysql-db-1                                     Healthy                                                                                                                                           0.5s
     ✔ DRY-RUN MODE -  Container nginx-golang-mysql-backend-1                                Started                                                                                                                                           0.0s
     ✔ DRY-RUN MODE -  Container nginx-golang-mysql-proxy-1                                  Started                                     Started
    ```
    From the example above, you can see that the first step is to pull the image defined by `db` service, then build the `backend` service.
    Next, the containers are created. The `db` service is started, and the `backend` and `proxy` wait until the `db` service is healthy before starting.

    Dry Run mode works with almost all commands. You cannot use Dry Run mode with a command that doesn't change the state of a Compose stack such as `ps`, `ls`, `logs` for example.
deprecated: false
hidden: false
experimental: false
experimentalcli: false
kubernetes: false
swarm: false