Search code examples
apachedockernetwork-programmingcontainershost

Multiple instances when using "Host" network mode?


Is it possible to have multiple apache-server instances running when using "host" networking? Just as it is possible with "bridged" networking & port mapping?

Or does other instances next to the "host" networking instance have to be "bridged" in order to map another port than 80 that might already be in use?


Solution

  • Anything that runs using host networking, well, uses the host networking. There is no isolation between your container, other host-networked containers, and processes running directly on the host. If you are running Apache on your host, and two --net host Apache containers, and they all try to bind to 0.0.0.0 port 80, they will conflict. You need to resolve this using application-specific configuration; there is no concept of port mapping in host networking mode.

    Particularly for straightforward HTTP/TCP services, host networking is almost never necessary. If you use standard bridged networking then applications in containers won’t conflict with each other or host processes. You can remap the ports to whatever is convenient for you, without worrying about reconfiguring the application.