How to make Network_Mode : "host" work in docker-compose.yml file

network_mode: host is used for sharing the same networking space with the Host. For example you can want to access an application that is running on your Linux PC from the container. If you want to link services together, you can use links, or depends_on, and if the services are on different hosts just create an overlay network


From docs:

network_mode: "host" cannot be mixed with links.

And about links

Warning: The --link flag is a legacy feature of Docker. It may eventually be removed. Unless you absolutely need to continue using it, we recommend that you use user-defined networks to facilitate communication between two containers instead of using --link. One feature that user-defined networks do not support that you can do with --link is sharing environmental variables between containers. However, you can use other mechanisms such as volumes to share environment variables between containers in a more controlled way.

Just remove the links. They are no longer required.