Merge pull request #20648 from dvdksn/compose-nw-driver-opt-example

compose: use real network driver_opts examples
This commit is contained in:
David Karlsson 2024-08-19 16:20:31 +02:00 committed by GitHub
commit ca7a7b9a03
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 22 additions and 21 deletions

View File

@ -119,14 +119,13 @@ services:
networks:
frontend:
# Use a custom driver
driver: custom-driver-1
backend:
# Use a custom driver which takes special options
driver: custom-driver-2
# Specify driver options
driver: bridge
driver_opts:
foo: "1"
bar: "2"
com.docker.network.bridge.host_binding_ipv4: "127.0.0.1"
backend:
# Use a custom driver
driver: custom-driver
```
Networks can be configured with static IP addresses by setting the [ipv4_address and/or ipv6_address](/reference/compose-file/services.md#ipv4_address-ipv6_address) for each attached network.

View File

@ -50,14 +50,13 @@ services:
networks:
frontend:
# Use a custom driver
driver: custom-driver-1
backend:
# Use a custom driver which takes special options
driver: custom-driver-2
# Specify driver options
driver: bridge
driver_opts:
foo: "1"
bar: "2"
com.docker.network.bridge.host_binding_ipv4: "127.0.0.1"
backend:
# Use a custom driver
driver: custom-driver
```
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.
@ -80,16 +79,18 @@ For more information on drivers and available options, see [Network drivers](/en
### driver_opts
`driver_opts` specifies a list of options as key-value pairs to pass to the driver. These options are
driver-dependent. Consult the driver's documentation for more information.
driver-dependent.
```yml
networks:
db-data:
frontend:
driver: bridge
driver_opts:
foo: "bar"
baz: 1
com.docker.network.bridge.host_binding_ipv4: "127.0.0.1"
```
Consult the [network drivers documentation](/engine/network/_index.md) for more information.
### attachable
If `attachable` is set to `true`, then standalone containers should be able to attach to this network, in addition to services.

View File

@ -563,7 +563,7 @@ dns_search:
{{< introduced compose 2.27.1 "/compose/release-notes.md#2271" >}}
`driver_opts` specifies a list of options as key-value pairs to pass to the driver. These options are
driver-dependent. Consult the driver's documentation for more information.
driver-dependent.
```yml
services:
@ -571,10 +571,11 @@ services:
networks:
app_net:
driver_opts:
foo: "bar"
baz: 1
com.docker.network.bridge.host_binding_ipv4: "127.0.0.1"
```
Consult the [network drivers documentation](/engine/network/_index.md) for more information.
### entrypoint
`entrypoint` declares the default entrypoint for the service container.