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
This commit is contained in:
Allie Sadler 2024-12-16 16:43:36 +00:00 committed by GitHub
parent de764a8138
commit 948b9cac9b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 50 additions and 2 deletions

View File

@ -153,6 +153,7 @@ kubectl
kubefwd
kubelet
lookup
label_file
macOS
macvlan
mfsymlinks

View File

@ -56,10 +56,36 @@ Compose to monitor source code for changes. For more information, see [Use Compo
`action` defines the action to take when changes are detected. If `action` is set to:
- `rebuild`, Compose rebuilds the service image based on the `build` section and recreates the service with the updated image.
- `restart`, Compose restarts the service container. Available with Docker Compose version 2.32.0 and later.
- `sync`, Compose keeps the existing service container(s) running, but synchronizes source files with container content according to the `target` attribute.
- `sync+restart`, Compose synchronizes source files with container content according to the `target` attribute, and then restarts the container.
- `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.
- `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.
> `sync+restart` attribute is available with Docker Compose version 2.23.0 and later.
#### exec
{{< introduced compose 2.23.2 "/manuals/compose/releases/release-notes.md#2232" >}}
`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.
- `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.
- `user`: The user to run the command. If not set, the command is run with the same user as the main service command.
- `privileged`: Lets the command run with privileged access.
- `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.
- `environment`: Sets the environment variables to run the command. While the command inherits the environment variables defined for the services main command, this section lets you add new variables or override existing ones.
```yaml
services:
frontend:
image: ...
develop:
watch:
# sync content then run command to reload service without interruption
- path: ./etc/config
action: sync+exec
target: /etc/config/
exec:
command: app reload
```
#### ignore

View File

@ -1152,6 +1152,27 @@ Compose creates containers with canonical labels:
The `com.docker.compose` label prefix is reserved. Specifying labels with this prefix in the Compose file
results in a runtime error.
### label_file
{{< introduced compose 2.23.2 "/manuals/compose/releases/release-notes.md#2232" >}}
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.
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.
```yaml
services:
one:
label_file: ./app.labels
two:
label_file:
- ./app.labels
- ./additional.labels
```
If a label is defined in both the `label_file` and the `labels` attribute, the value in [`labels](#labels) takes precedence.
### links
`links` defines a network link to containers in another service. Either specify both the service name and