Docker Community Forums

Share and learn in the Docker community.

Running containers sharing host network

Hello all,
I want to confirm this before deploying, if i run several containers, lets say one with Apache, other with Mysql and i used the host network

--network host

So they are using the host network, does it means they can interact directly using localhost? so a virtual host on Apache can reach the database with localhost address ?

Yes. It will put the network device of such a container into the network namespace of the host Thus, it will behaves network-wise like any other process on the host. localhost in the container will be the same localhost as on the host.