ENGDOCS-1993 (#19441)

* ENGDOCS-1993

* improve reset  and override example
This commit is contained in:
Allie Sadler 2024-02-21 08:55:49 +00:00 committed by GitHub
parent 6f85349dd1
commit 6d32e6e940
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 38 additions and 32 deletions

View File

@ -1151,7 +1151,7 @@ There is a performance penalty for applications that swap memory to disk often.
- `none`: Turns off all container networking. - `none`: Turns off all container networking.
- `host`: Gives the container raw access to the host's network interface. - `host`: Gives the container raw access to the host's network interface.
- `service:{name}`: Gives the containers access to the specified service only. - `service:{name}`: Gives the containers access to the specified service only. For more information, see [Container networks](../../network/_index.md#container-networks).
```yml ```yml
network_mode: "host" network_mode: "host"

View File

@ -145,41 +145,35 @@ For readability, it is recommended to explicitly set the attribute value to the
array `[]` (with `!reset null` or `!reset []`) so that it is clear that resulting attribute will be array `[]` (with `!reset null` or `!reset []`) so that it is clear that resulting attribute will be
cleared. cleared.
Merging the following example YAML trees: A base `compose.yaml` file:
```yaml ```yaml
services: services:
foo: app:
build: image: myapp
dockerfile: foo.Dockerfile
read_only: true
environment:
FOO: BAR
ports: ports:
- "8080:80" - "8080:80"
environment:
FOO: BAR
``` ```
And an `overide.compose.yaml` file:
```yaml ```yaml
services: services:
foo: app:
image: foo image: myapp
build: !reset null ports: !reset []
read_only: !reset false
environment: environment:
FOO: !reset null FOO: !reset null
ports: !reset []
``` ```
Result in a Compose application model equivalent to the YAML tree: Results in:
```yaml ```yaml
services: services:
foo: app:
image: foo image: myapp
build: null
read_only: false
environment: {}
ports: []
``` ```
### Replace value ### Replace value
@ -189,24 +183,36 @@ services:
While `!reset` can be used to remove a declaration from a Compose file using an override file, `!override` allows you While `!reset` can be used to remove a declaration from a Compose file using an override file, `!override` allows you
to fully replace an attribute, bypassing the standard merge rules. A typical example is to fully replace a resource definition, to rely on a distinct model but using the same name. to fully replace an attribute, bypassing the standard merge rules. A typical example is to fully replace a resource definition, to rely on a distinct model but using the same name.
Merging the following example YAML trees: A base `compose.yaml` file:
```yaml ```yaml
networks: services:
foo: app:
# this is production configuration image: myapp
name: production-overlay-network ports:
driver: overlay - "8080:80"
driver-opts: (...)
``` ```
To remove the original port, but expose a new one, the following override file is used:
```yaml ```yaml
networks: services:
# this is development configuration app:
foo: !override {} ports: !override
- "8443:443"
``` ```
Results in a Compose application model equivalent to the override YAML tree. This results in:
```yaml
services:
app:
image: myapp
ports:
- "8443:443"
```
If `!override` had not been used, both `8080:80` and `8443:443` would be exposed as per the [merging rules outlined above](#sequence).
## Additional resources ## Additional resources