From ef1198103e063194af3d4e12753fbce085aaba96 Mon Sep 17 00:00:00 2001 From: Daniel Villavicencio <danielvillavicencio@Daniels-MBP.attlocal.net> Date: Thu, 29 May 2025 20:43:32 -0700 Subject: [PATCH 1/2] Compose: add swarm and stack external host config example --- content/reference/compose-file/networks.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/content/reference/compose-file/networks.md b/content/reference/compose-file/networks.md index c8c30a3e1b5..b13d149766d 100644 --- a/content/reference/compose-file/networks.md +++ b/content/reference/compose-file/networks.md @@ -190,6 +190,27 @@ networks: external: true ``` +#### Accessing host network in Swarm mode with Stack +If you need to access the Docker host's network when using Swarm mode with `docker stack deploy`, +you can reference the network by declaring it as an external network: + +```yml +services: + my-service: + image: example/my-service + networks: + - outside + +networks: + outside: + external: + name: "host" +``` +> [!NOTE] +> Accessing the Docker host network adds certain limitations on services including restricted port mapping, lack of service replication, and +> exclusion from the Swarm's ingress routing mesh and service discovery. For more information, see [External Network Drivers](https://docs.docker.com/engine/network/drivers/host/) +> and [Swarm mode routing mesh](https://docs.docker.com/engine/swarm/ingress/) + ### `ipam` `ipam` specifies a custom IPAM configuration. This is an object with several properties, each of which is optional: From 0d85e2abd40c220eadb83dbce025ec29dc0363b4 Mon Sep 17 00:00:00 2001 From: Daniel Villavicencio <danielvillavicencio@Daniels-MBP.attlocal.net> Date: Thu, 29 May 2025 20:49:31 -0700 Subject: [PATCH 2/2] Added space around headings --- content/reference/compose-file/networks.md | 1 + 1 file changed, 1 insertion(+) diff --git a/content/reference/compose-file/networks.md b/content/reference/compose-file/networks.md index b13d149766d..435bb66780f 100644 --- a/content/reference/compose-file/networks.md +++ b/content/reference/compose-file/networks.md @@ -191,6 +191,7 @@ networks: ``` #### Accessing host network in Swarm mode with Stack + If you need to access the Docker host's network when using Swarm mode with `docker stack deploy`, you can reference the network by declaring it as an external network: