Skip to content

Commit ef11981

Browse files
Daniel VillavicencioDaniel Villavicencio
authored andcommitted
Compose: add swarm and stack external host config example
1 parent f23f120 commit ef11981

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

content/reference/compose-file/networks.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,27 @@ networks:
190190
external: true
191191
```
192192

193+
#### Accessing host network in Swarm mode with Stack
194+
If you need to access the Docker host's network when using Swarm mode with `docker stack deploy`,
195+
you can reference the network by declaring it as an external network:
196+
197+
```yml
198+
services:
199+
my-service:
200+
image: example/my-service
201+
networks:
202+
- outside
203+
204+
networks:
205+
outside:
206+
external:
207+
name: "host"
208+
```
209+
> [!NOTE]
210+
> Accessing the Docker host network adds certain limitations on services including restricted port mapping, lack of service replication, and
211+
> 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/)
212+
> and [Swarm mode routing mesh](https://docs.docker.com/engine/swarm/ingress/)
213+
193214
### `ipam`
194215

195216
`ipam` specifies a custom IPAM configuration. This is an object with several properties, each of which is optional:

0 commit comments

Comments
 (0)