I need to run containers from docker-compose in host network mode. For example, if I run single container, I write:
docker run --net=host my_image
How to do this part --net=host in docker-compose?
The equivalent in docker-comopose is network_mode: host see the documentation in: https://docs.docker.com/compose/compose-file/
add directory network_mode of the networks section to your service definition in your docker-compose.yml
also, pay attention network_mode is incompatible with port_bindings:
version: '3.5'
services:
server:
image: custome image
container_name: "sample"
command: bash -c "python sample.py"
network_mode: host