Skip to content

Commit f1a87f4

Browse files
authored
ENGDOCS-2382 (#21848)
<!--Delete sections as needed --> ## Description Some Compose spec updates: Adds compose-spec/compose-spec#557 Adds compose-spec/compose-spec#555 ## 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 228cc0f commit f1a87f4

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

content/reference/compose-file/services.md

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -257,16 +257,21 @@ cgroup_parent: m-executor-abcd
257257
command: bundle exec thin -p 3000
258258
```
259259

260-
The value can also be a list, in a manner similar to [Dockerfile](https://docs.docker.com/reference/dockerfile/#cmd):
261-
262-
```yaml
263-
command: [ "bundle", "exec", "thin", "-p", "3000" ]
264-
```
265-
266260
If the value is `null`, the default command from the image is used.
267261

268262
If the value is `[]` (empty list) or `''` (empty string), the default command declared by the image is ignored, or in other words overridden to be empty.
269263

264+
> [!NOTE]
265+
>
266+
> Unlike the `CMD` instruction in a Dockerfile, the `command` field doesn't automatically run within the context of the [`SHELL`](/reference/dockerfile.md#shell-form) instruction defined in the image. If your `command` relies on shell-specific features, such as environment variable expansion, you need to explicitly run it within a shell. For example:
267+
>
268+
> ```yaml
269+
> command: /bin/sh -c 'echo "hello $$HOSTNAME"'
270+
> ```
271+
272+
The value can also be a list, similar to the [exec-form syntax](/reference/dockerfile.md#exec-form)
273+
used by the [Dockerfile](/reference/dockerfile.md#exec-form).
274+
270275
### `configs`
271276

272277
`configs` let services adapt their behaviour without the need to rebuild a Docker image.
@@ -766,11 +771,11 @@ extends:
766771
- `service`: Defines the name of the service being referenced as a base, for example `web` or `database`.
767772
- `file`: The location of a Compose configuration file defining that service.
768773

769-
When a service uses `extends`, it can also specify dependencies on other resources, an explicit `volumes` declaration for instance. However, it's important to note that `extends` does not automatically incorporate the target volume definition into the extending Compose file. Instead, you are responsible for ensuring that an equivalent resource exists for the service being extended to maintain consistency. Docker Compose verifies that a resource with the referenced ID is present within the Compose model.
774+
#### Restrictions
775+
776+
When a service is referenced using `extends`, it can declare dependencies on other resources. These dependencies may be explicitly defined through attributes like `volumes`, `networks`, `configs`, `secrets`, `links`, `volumes_from`, or `depends_on`. Alternatively, dependencies can reference another service using the `service:{name}` syntax in namespace declarations such as `ipc`, `pid`, or `network_mode`.
770777

771-
Dependencies on other resources in an `extends` target can be:
772-
- An explicit reference by `volumes`, `networks`, `configs`, `secrets`, `links`, `volumes_from` or `depends_on`
773-
- A reference to another service using the `service:{name}` syntax in namespace declaration (`ipc`, `pid`, `network_mode`)
778+
Compose does not automatically import these referenced resources into the extended model. It is your responsibility to ensure all required resources are explicitly declared in the model that relies on extends.
774779

775780
Circular references with `extends` are not supported, Compose returns an error when one is detected.
776781

0 commit comments

Comments
 (0)