From 6fb791112464144ff9e8f0fa674dc4c4febb9a7b Mon Sep 17 00:00:00 2001 From: Misty Stanley-Jones Date: Fri, 13 Oct 2017 15:11:25 -0700 Subject: [PATCH 1/2] Add info about network: host --- compose/compose-file/compose-file-v2.md | 43 +++++++++++++++++++++++++ compose/compose-file/index.md | 39 ++++++++++++++++++++++ 2 files changed, 82 insertions(+) diff --git a/compose/compose-file/compose-file-v2.md b/compose/compose-file/compose-file-v2.md index a21b40a5d7ee..0d973a95c2aa 100644 --- a/compose/compose-file/compose-file-v2.md +++ b/compose/compose-file/compose-file-v2.md @@ -1415,6 +1415,49 @@ refer to it within the Compose file: external: name: actual-name-of-network +#### 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 +version: 2 + +services: + web: + ... + networks: + hostnet: {} + +networks: + hostnet: + external: + name: host +``` + +```yaml +version: 2 + +services: + web: + ... + networks: + nonet: {} + +networks: + nonet: + external: + name: none +``` + ## Variable substitution {% include content/compose-var-sub.md %} diff --git a/compose/compose-file/index.md b/compose/compose-file/index.md index 90a512096560..542c88ad9cc3 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 From 874d1badc3f034289c33450e8271e45011c3fede Mon Sep 17 00:00:00 2001 From: Misty Stanley-Jones Date: Fri, 20 Oct 2017 16:03:02 -0700 Subject: [PATCH 2/2] Address feedback --- compose/compose-file/compose-file-v2.md | 42 ++----------------------- compose/compose-file/index.md | 2 +- 2 files changed, 3 insertions(+), 41 deletions(-) diff --git a/compose/compose-file/compose-file-v2.md b/compose/compose-file/compose-file-v2.md index 0d973a95c2aa..137aaded4741 100644 --- a/compose/compose-file/compose-file-v2.md +++ b/compose/compose-file/compose-file-v2.md @@ -1417,46 +1417,8 @@ refer to it within the Compose file: #### 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 -version: 2 - -services: - web: - ... - networks: - hostnet: {} - -networks: - hostnet: - external: - name: host -``` - -```yaml -version: 2 - -services: - web: - ... - networks: - nonet: {} - -networks: - nonet: - external: - name: none -``` +Not supposed for version 2 `docker-compose` files. Use +[network_mode](#network_mode) instead. ## Variable substitution diff --git a/compose/compose-file/index.md b/compose/compose-file/index.md index 542c88ad9cc3..970012f36228 100644 --- a/compose/compose-file/index.md +++ b/compose/compose-file/index.md @@ -1946,7 +1946,7 @@ Architecture](https://github.com/docker/labs/blob/master/networking/concepts/06- 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, +`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