Skip to main content

What is the host network?

host is a type of Docker network in which the container does not get its own network space, but uses the host's network stack directly. In other words, the container "lives" on the host machine's network and works as a regular process on it.


What this looks like

  • the container has no separate IP address;
  • it uses the host's IP;
  • the container's ports and the host's ports are the same thing.

Example run:

bash
docker run --network host nginx

Now Nginx is accessible on the host's port without -p 80:80.


When this is convenient

  • when maximum network speed is needed (no NAT);
  • when the application works with network interfaces directly (VPN, monitoring, network daemons);
  • when direct access to the host's localhost matters.

Downsides

DownsideThe gist
No isolationThe container shares the network with the host, higher risk
Possible port conflictsOne port for the whole server
Less flexibleHarder to manage network rules

Summary

The host network is a mode in which Docker disables network isolation, and the container runs on the host's network. It is fast and "direct", but less secure and less flexible compared to bridge.

Short Answer

Interview ready
Premium

A concise answer to help you respond confidently on this topic during an interview.