Home Explore Blog Models CI



docker

1st chunk of `content/manuals/engine/network/drivers/host.md`
47f869ee0f68dcf172cea7b590cf29140993954a27a6f9590000000100000861
---
title: Host network driver
description: All about exposing containers on the Docker host's network
keywords: network, host, standalone, host mode networking
aliases:
- /network/host/
- /network/drivers/host/
---

If you use the `host` network mode for a container, that container's network
stack isn't isolated from the Docker host (the container shares the host's
networking namespace), and the container doesn't get its own IP-address allocated.
For instance, if you run a container which binds to port 80 and you use `host`
networking, the container's application is available on port 80 on the host's IP
address.

> [!NOTE]
>
> Given that the container does not have its own IP-address when using
> `host` mode networking, [port-mapping](overlay.md#publish-ports) doesn't
> take effect, and the `-p`, `--publish`, `-P`, and `--publish-all` option are
> ignored, producing a warning instead:
>
> ```console
> WARNING: Published ports are discarded when using host network mode
> ```

Host mode networking can be useful for the following use cases:

- To optimize performance
- In situations where a container needs to handle a large range of ports

This is because it doesn't require network address translation (NAT), and no "userland-proxy" is created for each port.

The host networking driver is supported on Docker Engine (Linux only) and Docker Desktop version 4.34 and later.

You can also use a `host` network for a swarm service, by passing `--network host`
to the `docker service create` command. In this case, control traffic (traffic
related to managing the swarm and the service) is still sent across an overlay
network, but the individual swarm service containers send data using the Docker
daemon's host network and ports. This creates some extra limitations. For instance,
if a service container binds to port 80, only one service container can run on a
given swarm node.

## Docker Desktop

Host networking is supported on Docker Desktop version 4.34 and later.
To enable this feature:

1. Sign in to your Docker account in Docker Desktop.
2. Navigate to **Settings**.
3. Under the **Resources** tab, select **Network**.

Title: Host Network Driver in Docker
Summary
The `host` network mode in Docker allows a container to share the host's network stack, eliminating network isolation. This improves performance and is useful when a container needs to handle a large range of ports, as it avoids NAT and userland proxies. This mode is supported on Docker Engine (Linux only) and Docker Desktop version 4.34 and later. Using `host` networking with Swarm services sends control traffic over an overlay network but uses the host network for data, which can create limitations. In Docker Desktop, it can be enabled in the settings under the 'Resources' -> 'Network' tab.