Skip to content

Compose: Add guidance for using host network in Swarm mode and Docker Stack #22724

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions content/reference/compose-file/networks.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,28 @@ 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:
Expand Down