# HOST Networking in Docker

In 
Published 2022-12-03

This tutorial explains host networking mode in Docker.

Here is the picture which shows how host networking is working:

Here are the main things to retain:

  • the containers created with --network host use the networking namespace of the host.
  • make the programs inside the Docker container look like they are running on the host itself, from the perspective of the network.

For instance, in the example above, you can access the HTTP Server from the container 2, from the host, using http://localhost:8081 as the HTTP server is running directly on the host machine.

  • you no longer have to maps the container ports to the host ports, but you have to set up ports which are not in conflict with other containers or with other services which run on the host machine.

  • You can start a Docker container in host networking mode as in the following example:

linux
docker run -d --network host httpd:latest
  • The host networking driver only works on Linux hosts, and is not supported on Docker Desktop for Mac, Docker Desktop for Windows, or Docker EE for Windows Server.