diff --git a/compose/compose-file/compose-file-v2.md b/compose/compose-file/compose-file-v2.md index 0c7f1de012..50723cce8d 100644 --- a/compose/compose-file/compose-file-v2.md +++ b/compose/compose-file/compose-file-v2.md @@ -1418,6 +1418,11 @@ refer to it within the Compose file: external: name: actual-name-of-network +#### host or none + +Not supposed for version 2 `docker-compose` files. Use +[network_mode](#network_mode) instead. + ## Variable substitution {% include content/compose-var-sub.md %} diff --git a/compose/compose-file/index.md b/compose/compose-file/index.md index f5168df291..11d08214f8 100644 --- a/compose/compose-file/index.md +++ b/compose/compose-file/index.md @@ -1942,6 +1942,45 @@ discovery](https://github.com/docker/labs/blob/master/networking/A3-overlay-netw networking concepts lab on the [Overlay Driver Network Architecture](https://github.com/docker/labs/blob/master/networking/concepts/06-overlay-networks.md). +#### host or none + +Use the host's networking stack, or no networking. Equivalent to +`docker run --net=host` or `docker run --net=none`. Only used if you use +`docker stack` commands. If you use the `docker-compose` command, +use [network_mode](#network_mode) instead. + +The syntax for using built-in networks like `host` and `none` is a little +different. Define an external network with the name `host` or `none` (which +Docker has already created automatically) and an alias that Compose can use +(`hostnet` or `nonet` in these examples), then grant the service access to that +network, using the alias. + +```yaml +services: + web: + ... + networks: + hostnet: {} + +networks: + hostnet: + external: + name: host +``` + +```yaml +services: + web: + ... + networks: + nonet: {} + +networks: + nonet: + external: + name: none +``` + ### driver_opts Specify a list of options as key-value pairs to pass to the driver for this