diff --git a/_vale/config/vocabularies/Docker/accept.txt b/_vale/config/vocabularies/Docker/accept.txt index 97b29fc633..2dceba9aac 100644 --- a/_vale/config/vocabularies/Docker/accept.txt +++ b/_vale/config/vocabularies/Docker/accept.txt @@ -153,6 +153,7 @@ kubectl kubefwd kubelet lookup +label_file macOS macvlan mfsymlinks diff --git a/content/reference/compose-file/develop.md b/content/reference/compose-file/develop.md index 1e48a00ff2..d08ad90a31 100644 --- a/content/reference/compose-file/develop.md +++ b/content/reference/compose-file/develop.md @@ -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 service’s 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 diff --git a/content/reference/compose-file/services.md b/content/reference/compose-file/services.md index 90999a93bf..73ec17d5ce 100644 --- a/content/reference/compose-file/services.md +++ b/content/reference/compose-file/services.md @@ -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