From 6a276b994027ac75ab96829ac40b6e1daa3c1a7f Mon Sep 17 00:00:00 2001 From: aevesdocker Date: Mon, 17 Mar 2025 11:50:14 +0000 Subject: [PATCH 1/7] ENGDOCS-2489 --- content/reference/compose-file/merge.md | 2 +- content/reference/compose-file/networks.md | 32 +++++++++++++++++ content/reference/compose-file/services.md | 42 +++++++++++++++++++--- 3 files changed, 71 insertions(+), 5 deletions(-) diff --git a/content/reference/compose-file/merge.md b/content/reference/compose-file/merge.md index 2c50ce4359db..7b9a5784831d 100644 --- a/content/reference/compose-file/merge.md +++ b/content/reference/compose-file/merge.md @@ -142,7 +142,7 @@ services: In addition to the previously described mechanism, an override Compose file can also be used to remove elements from your application model. For this purpose, the custom [YAML tag](https://yaml.org/spec/1.2.2/#24-tags) `!reset` can be set to -override a value set by the overriden Compose file. A valid value for attribute must be provided, +override a value set by the overridden Compose file. A valid value for attribute must be provided, but will be ignored and target attribute will be set with type's default value or `null`. For readability, it is recommended to explicitly set the attribute value to the null (`null`) or empty diff --git a/content/reference/compose-file/networks.md b/content/reference/compose-file/networks.md index a1ae916e4c32..3e97efe6a02f 100644 --- a/content/reference/compose-file/networks.md +++ b/content/reference/compose-file/networks.md @@ -62,6 +62,38 @@ networks: The advanced example shows a Compose file which defines two custom networks. The `proxy` service is isolated from the `db` service, because they do not share a network in common. Only `app` can talk to both. +## The default network + +When a Compose file doesn't declare explicit networks, Compose uses an implicit `default` network. Services without an explicit [`networks`](05-services.md#networks) declaration are connected by Compose to this `default` network: + + +```yml +services: + some-service: + image: foo +``` +This example is actually equivalent to: + +```yml +services: + some-service: + image: foo + networks: + default: {} +networks: + default: {} +``` + +You can customize the `default` network with an explicit declaration: + +```yml +networks: + default: + name: a_network # Use a custom name + driver_opts: # pass [options](https://docs.docker.com/engine/network/drivers/bridge/#options) to driver for network creation + com.docker.network.bridge.host_binding_ipv4: 127.0.0.1 +``` + ## Attributes ### `driver` diff --git a/content/reference/compose-file/services.md b/content/reference/compose-file/services.md index 017481feb6ea..a64f28e2754c 100644 --- a/content/reference/compose-file/services.md +++ b/content/reference/compose-file/services.md @@ -1321,6 +1321,28 @@ services: ``` For more information about the `networks` top-level element, see [Networks](networks.md). +### implicit default network + +If `networks` is empty or absent from the Compose file, Compose considers an implicit definition for the service to be +connected to the `default` network: + +```yml +services: + some-service: + image: foo +``` +This example is actually equivalent to: + +```yml +services: + some-service: + image: foo + networks: + default: {} +``` + +If you want the service to not be connected a network, you must set [`network_mode: none`](#network_mode). + #### `aliases` `aliases` declares alternative hostnames for the service on the network. Other containers on the same @@ -1675,13 +1697,23 @@ services: `pull_policy` defines the decisions Compose makes when it starts to pull images. Possible values are: -* `always`: Compose always pulls the image from the registry. -* `never`: Compose doesn't pull the image from a registry and relies on the platform cached image. +- `always`: Compose always pulls the image from the registry. +- `never`: Compose doesn't pull the image from a registry and relies on the platform cached image. If there is no cached image, a failure is reported. -* `missing`: Compose pulls the image only if it's not available in the platform cache. +- `missing`: Compose pulls the image only if it's not available in the platform cache. This is the default option if you are not also using the [Compose Build Specification](build.md). `if_not_present` is considered an alias for this value for backward compatibility. -* `build`: Compose builds the image. Compose rebuilds the image if it's already present. +- `build`: Compose builds the image. Compose rebuilds the image if it's already present. +- `daily`: Compose checks the registry for image updates if the last pull took place more than 24 hours ago. +- `weekly`: Compose checks the registry for image updates if the last pull took place more than 7 days ago. +- `every_`: Compose checks the registry for image updates if the last pull took place before ``. Duration can be expressed in weeks (`w`), days (`d`), hours (`h`), minutes (`m`), seconds (`s`) or a combination of these. + +```yaml +services: + test: + image: nginx + pull_policy: every_12h +``` ### `read_only` @@ -1779,6 +1811,8 @@ the service's containers. The default value is world-readable permissions (mode `0444`). The writable bit must be ignored if set. The executable bit may be set. +Note that support for `uid`, `gid`, and `mode` attributes are not implemented in Docker Compose when the source of the secret is a [`file`](09-secrets.md). This is because bind-mounts used under the hood don't allow uid remapping. + The following example sets the name of the `server-certificate` secret file to `server.cert` within the container, sets the mode to `0440` (group-readable), and sets the user and group to `103`. The value of `server-certificate` is set From 5b312d285c8f45e7c2592d0223ae30e8cd953d59 Mon Sep 17 00:00:00 2001 From: aevesdocker Date: Mon, 17 Mar 2025 11:55:32 +0000 Subject: [PATCH 2/7] fix build --- content/reference/compose-file/networks.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/content/reference/compose-file/networks.md b/content/reference/compose-file/networks.md index 3e97efe6a02f..b39bba8a8736 100644 --- a/content/reference/compose-file/networks.md +++ b/content/reference/compose-file/networks.md @@ -90,10 +90,12 @@ You can customize the `default` network with an explicit declaration: networks: default: name: a_network # Use a custom name - driver_opts: # pass [options](https://docs.docker.com/engine/network/drivers/bridge/#options) to driver for network creation + driver_opts: # pass optionsto driver for network creation com.docker.network.bridge.host_binding_ipv4: 127.0.0.1 ``` +For options, see the [Docker Engine docs](https://docs.docker.com/engine/network/drivers/bridge/#options). + ## Attributes ### `driver` From 355232cf6e1d6ede7b4e3700f1c6e8158266681a Mon Sep 17 00:00:00 2001 From: aevesdocker Date: Mon, 17 Mar 2025 11:58:54 +0000 Subject: [PATCH 3/7] fix build --- content/reference/compose-file/networks.md | 2 +- content/reference/compose-file/services.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/content/reference/compose-file/networks.md b/content/reference/compose-file/networks.md index b39bba8a8736..6248274d50c9 100644 --- a/content/reference/compose-file/networks.md +++ b/content/reference/compose-file/networks.md @@ -64,7 +64,7 @@ The advanced example shows a Compose file which defines two custom networks. The ## The default network -When a Compose file doesn't declare explicit networks, Compose uses an implicit `default` network. Services without an explicit [`networks`](05-services.md#networks) declaration are connected by Compose to this `default` network: +When a Compose file doesn't declare explicit networks, Compose uses an implicit `default` network. Services without an explicit [`networks`](services.md#networks) declaration are connected by Compose to this `default` network: ```yml diff --git a/content/reference/compose-file/services.md b/content/reference/compose-file/services.md index a64f28e2754c..e6afb51ecfe7 100644 --- a/content/reference/compose-file/services.md +++ b/content/reference/compose-file/services.md @@ -1811,7 +1811,7 @@ the service's containers. The default value is world-readable permissions (mode `0444`). The writable bit must be ignored if set. The executable bit may be set. -Note that support for `uid`, `gid`, and `mode` attributes are not implemented in Docker Compose when the source of the secret is a [`file`](09-secrets.md). This is because bind-mounts used under the hood don't allow uid remapping. +Note that support for `uid`, `gid`, and `mode` attributes are not implemented in Docker Compose when the source of the secret is a [`file`](secrets.md). This is because bind-mounts used under the hood don't allow uid remapping. The following example sets the name of the `server-certificate` secret file to `server.cert` within the container, sets the mode to `0440` (group-readable), and sets the user and group From 2d2487d9adb8f38b84c5501b4936fbf106a9d355 Mon Sep 17 00:00:00 2001 From: Allie Sadler <102604716+aevesdocker@users.noreply.github.com> Date: Mon, 17 Mar 2025 12:04:11 +0000 Subject: [PATCH 4/7] Update content/reference/compose-file/networks.md --- content/reference/compose-file/networks.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/reference/compose-file/networks.md b/content/reference/compose-file/networks.md index 6248274d50c9..c8c30a3e1b58 100644 --- a/content/reference/compose-file/networks.md +++ b/content/reference/compose-file/networks.md @@ -90,7 +90,7 @@ You can customize the `default` network with an explicit declaration: networks: default: name: a_network # Use a custom name - driver_opts: # pass optionsto driver for network creation + driver_opts: # pass options to driver for network creation com.docker.network.bridge.host_binding_ipv4: 127.0.0.1 ``` From 2c62e5ec5683e6f4e78df4352a0ade470b11fe4d Mon Sep 17 00:00:00 2001 From: Allie Sadler <102604716+aevesdocker@users.noreply.github.com> Date: Mon, 17 Mar 2025 12:04:24 +0000 Subject: [PATCH 5/7] Update content/reference/compose-file/networks.md From 67abdc48f423e25e8ffb9fb598985e10ebfe3473 Mon Sep 17 00:00:00 2001 From: Allie Sadler <102604716+aevesdocker@users.noreply.github.com> Date: Mon, 17 Mar 2025 12:05:09 +0000 Subject: [PATCH 6/7] Update content/reference/compose-file/networks.md From c6584fa1b8281e8707b10aad8e44acd796f281b3 Mon Sep 17 00:00:00 2001 From: Allie Sadler <102604716+aevesdocker@users.noreply.github.com> Date: Mon, 17 Mar 2025 14:51:24 +0000 Subject: [PATCH 7/7] Update content/reference/compose-file/services.md --- content/reference/compose-file/services.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/reference/compose-file/services.md b/content/reference/compose-file/services.md index e6afb51ecfe7..3b14cc48590b 100644 --- a/content/reference/compose-file/services.md +++ b/content/reference/compose-file/services.md @@ -1321,7 +1321,7 @@ services: ``` For more information about the `networks` top-level element, see [Networks](networks.md). -### implicit default network +### Implicit default network If `networks` is empty or absent from the Compose file, Compose considers an implicit definition for the service to be connected to the `default` network: