File: docker_compose_run.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 (305 lines) | stat: -rw-r--r-- 9,023 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
command: docker compose run
short: Run a one-off command on a service
long: |-
    Runs a one-time command against a service.

    The following command starts the `web` service and runs `bash` as its command:

    ```console
    $ docker compose run web bash
    ```

    Commands you use with run start in new containers with configuration defined by that of the service,
    including volumes, links, and other details. However, there are two important differences:

    First, the command passed by `run` overrides the command defined in the service configuration. For example, if the
    `web` service configuration is started with `bash`, then `docker compose run web python app.py` overrides it with
    `python app.py`.

    The second difference is that the `docker compose run` command does not create any of the ports specified in the
    service configuration. This prevents port collisions with already-open ports. If you do want the service’s ports
    to be created and mapped to the host, specify the `--service-ports`

    ```console
    $ docker compose run --service-ports web python manage.py shell
    ```

    Alternatively, manual port mapping can be specified with the `--publish` or `-p` options, just as when using docker run:

    ```console
    $ docker compose run --publish 8080:80 -p 2022:22 -p 127.0.0.1:2021:21 web python manage.py shell
    ```

    If you start a service configured with links, the run command first checks to see if the linked service is running
    and starts the service if it is stopped. Once all the linked services are running, the run executes the command you
    passed it. For example, you could run:

    ```console
    $ docker compose run db psql -h db -U docker
    ```

    This opens an interactive PostgreSQL shell for the linked `db` container.

    If you do not want the run command to start linked containers, use the `--no-deps` flag:

    ```console
    $ docker compose run --no-deps web python manage.py shell
    ```

    If you want to remove the container after running while overriding the container’s restart policy, use the `--rm` flag:

    ```console
    $ docker compose run --rm web python manage.py db upgrade
    ```

    This runs a database upgrade script, and removes the container when finished running, even if a restart policy is
    specified in the service configuration.
usage: docker compose run [OPTIONS] SERVICE [COMMAND] [ARGS...]
pname: docker compose
plink: docker_compose.yaml
options:
    - option: build
      value_type: bool
      default_value: "false"
      description: Build image before starting container
      deprecated: false
      hidden: false
      experimental: false
      experimentalcli: false
      kubernetes: false
      swarm: false
    - option: cap-add
      value_type: list
      description: Add Linux capabilities
      deprecated: false
      hidden: false
      experimental: false
      experimentalcli: false
      kubernetes: false
      swarm: false
    - option: cap-drop
      value_type: list
      description: Drop Linux capabilities
      deprecated: false
      hidden: false
      experimental: false
      experimentalcli: false
      kubernetes: false
      swarm: false
    - option: detach
      shorthand: d
      value_type: bool
      default_value: "false"
      description: Run container in background and print container ID
      deprecated: false
      hidden: false
      experimental: false
      experimentalcli: false
      kubernetes: false
      swarm: false
    - option: entrypoint
      value_type: string
      description: Override the entrypoint of the image
      deprecated: false
      hidden: false
      experimental: false
      experimentalcli: false
      kubernetes: false
      swarm: false
    - option: env
      shorthand: e
      value_type: stringArray
      default_value: '[]'
      description: Set environment variables
      deprecated: false
      hidden: false
      experimental: false
      experimentalcli: false
      kubernetes: false
      swarm: false
    - option: interactive
      shorthand: i
      value_type: bool
      default_value: "true"
      description: Keep STDIN open even if not attached
      deprecated: false
      hidden: false
      experimental: false
      experimentalcli: false
      kubernetes: false
      swarm: false
    - option: label
      shorthand: l
      value_type: stringArray
      default_value: '[]'
      description: Add or override a label
      deprecated: false
      hidden: false
      experimental: false
      experimentalcli: false
      kubernetes: false
      swarm: false
    - option: name
      value_type: string
      description: Assign a name to the container
      deprecated: false
      hidden: false
      experimental: false
      experimentalcli: false
      kubernetes: false
      swarm: false
    - option: no-TTY
      shorthand: T
      value_type: bool
      default_value: "true"
      description: 'Disable pseudo-TTY allocation (default: auto-detected)'
      deprecated: false
      hidden: false
      experimental: false
      experimentalcli: false
      kubernetes: false
      swarm: false
    - option: no-deps
      value_type: bool
      default_value: "false"
      description: Don't start linked services
      deprecated: false
      hidden: false
      experimental: false
      experimentalcli: false
      kubernetes: false
      swarm: false
    - option: publish
      shorthand: p
      value_type: stringArray
      default_value: '[]'
      description: Publish a container's port(s) to the host
      deprecated: false
      hidden: false
      experimental: false
      experimentalcli: false
      kubernetes: false
      swarm: false
    - option: pull
      value_type: string
      default_value: policy
      description: Pull image before running ("always"|"missing"|"never")
      deprecated: false
      hidden: false
      experimental: false
      experimentalcli: false
      kubernetes: false
      swarm: false
    - option: quiet-pull
      value_type: bool
      default_value: "false"
      description: Pull without printing progress information
      deprecated: false
      hidden: false
      experimental: false
      experimentalcli: false
      kubernetes: false
      swarm: false
    - option: remove-orphans
      value_type: bool
      default_value: "false"
      description: Remove containers for services not defined in the Compose file
      deprecated: false
      hidden: false
      experimental: false
      experimentalcli: false
      kubernetes: false
      swarm: false
    - option: rm
      value_type: bool
      default_value: "false"
      description: Automatically remove the container when it exits
      deprecated: false
      hidden: false
      experimental: false
      experimentalcli: false
      kubernetes: false
      swarm: false
    - option: service-ports
      shorthand: P
      value_type: bool
      default_value: "false"
      description: |
        Run command with all service's ports enabled and mapped to the host
      deprecated: false
      hidden: false
      experimental: false
      experimentalcli: false
      kubernetes: false
      swarm: false
    - option: tty
      shorthand: t
      value_type: bool
      default_value: "true"
      description: Allocate a pseudo-TTY
      deprecated: false
      hidden: true
      experimental: false
      experimentalcli: false
      kubernetes: false
      swarm: false
    - option: use-aliases
      value_type: bool
      default_value: "false"
      description: |
        Use the service's network useAliases in the network(s) the container connects to
      deprecated: false
      hidden: false
      experimental: false
      experimentalcli: false
      kubernetes: false
      swarm: false
    - option: user
      shorthand: u
      value_type: string
      description: Run as specified username or uid
      deprecated: false
      hidden: false
      experimental: false
      experimentalcli: false
      kubernetes: false
      swarm: false
    - option: volume
      shorthand: v
      value_type: stringArray
      default_value: '[]'
      description: Bind mount a volume
      deprecated: false
      hidden: false
      experimental: false
      experimentalcli: false
      kubernetes: false
      swarm: false
    - option: workdir
      shorthand: w
      value_type: string
      description: Working directory inside the container
      deprecated: false
      hidden: false
      experimental: false
      experimentalcli: false
      kubernetes: false
      swarm: false
inherited_options:
    - 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
deprecated: false
hidden: false
experimental: false
experimentalcli: false
kubernetes: false
swarm: false