Skip to content

Commit 948b9ca

Browse files
authored
ENGDOCS-2332 (#21639)
<!--Delete sections as needed --> ## Description Adds new attributes to the spec from the recent 2.32.0 release ## Related issues or tickets <!-- Related issues, pull requests, or Jira tickets --> ## Reviews <!-- Notes for reviewers here --> <!-- List applicable reviews (optionally @tag reviewers) --> - [ ] Technical review - [ ] Editorial review - [ ] Product review
1 parent de764a8 commit 948b9ca

File tree

3 files changed

+50
-2
lines changed

3 files changed

+50
-2
lines changed

_vale/config/vocabularies/Docker/accept.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ kubectl
153153
kubefwd
154154
kubelet
155155
lookup
156+
label_file
156157
macOS
157158
macvlan
158159
mfsymlinks

content/reference/compose-file/develop.md

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,36 @@ Compose to monitor source code for changes. For more information, see [Use Compo
5656
`action` defines the action to take when changes are detected. If `action` is set to:
5757

5858
- `rebuild`, Compose rebuilds the service image based on the `build` section and recreates the service with the updated image.
59+
- `restart`, Compose restarts the service container. Available with Docker Compose version 2.32.0 and later.
5960
- `sync`, Compose keeps the existing service container(s) running, but synchronizes source files with container content according to the `target` attribute.
60-
- `sync+restart`, Compose synchronizes source files with container content according to the `target` attribute, and then restarts the container.
61+
- `sync+restart`, Compose synchronizes source files with container content according to the `target` attribute, and then restarts the container. Available with Docker Compose version 2.23.0 and later.
62+
- `sync+exec`, Compose synchronizes source files with container content according to the `target` attribute, and then executes a command inside the container. Available with Docker Compose version 2.32.0 and later.
6163

62-
> `sync+restart` attribute is available with Docker Compose version 2.23.0 and later.
64+
#### exec
65+
66+
{{< introduced compose 2.23.2 "/manuals/compose/releases/release-notes.md#2232" >}}
67+
68+
`exec` is only relevant when `action` is set to `sync+exec`. Like [service hooks](services.md#post_start), `exec` is used to define the command to be run inside the container once it has started.
69+
70+
- `command`: Specifies the command to run once the container starts. This attribute is required, and you can choose to use either the shell form or the exec form.
71+
- `user`: The user to run the command. If not set, the command is run with the same user as the main service command.
72+
- `privileged`: Lets the command run with privileged access.
73+
- `working_dir`: The working directory in which to run the command. If not set, it is run in the same working directory as the main service command.
74+
- `environment`: Sets the environment variables to run the command. While the command inherits the environment variables defined for the service’s main command, this section lets you add new variables or override existing ones.
75+
76+
```yaml
77+
services:
78+
frontend:
79+
image: ...
80+
develop:
81+
watch:
82+
# sync content then run command to reload service without interruption
83+
- path: ./etc/config
84+
action: sync+exec
85+
target: /etc/config/
86+
exec:
87+
command: app reload
88+
```
6389

6490
#### ignore
6591

content/reference/compose-file/services.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1152,6 +1152,27 @@ Compose creates containers with canonical labels:
11521152
The `com.docker.compose` label prefix is reserved. Specifying labels with this prefix in the Compose file
11531153
results in a runtime error.
11541154

1155+
### label_file
1156+
1157+
{{< introduced compose 2.23.2 "/manuals/compose/releases/release-notes.md#2232" >}}
1158+
1159+
The `label_file` attribute lets you load labels for a service from an external file or a list of files. This provides a convenient way to manage multiple labels without cluttering the Compose file.
1160+
1161+
The file uses a key-value format, similar to `env_file`. You can specify multiple files as a list. When using multiple files, they are processed in the order they appear in the list. If the same label is defined in multiple files, the value from the last file in the list overrides earlier ones.
1162+
1163+
```yaml
1164+
services:
1165+
one:
1166+
label_file: ./app.labels
1167+
1168+
two:
1169+
label_file:
1170+
- ./app.labels
1171+
- ./additional.labels
1172+
```
1173+
1174+
If a label is defined in both the `label_file` and the `labels` attribute, the value in [`labels](#labels) takes precedence.
1175+
11551176
### links
11561177

11571178
`links` defines a network link to containers in another service. Either specify both the service name and

0 commit comments

Comments
 (0)