I have two container that needs to communicate with each other.
One of the containers needs to be on the host network to send&receive udp multicast packages.
How can i do this with docker compose?
I got it working when i deploy the container per hand and use the container IPs.
But thats not suitable and feels like there must be a better way.
I want that the container that has its network type set to “host”, but its still possible to resolve other docker container names like they are on the same bridge network.
version: "2"
services:
database:
image: mongo
container_name: database
hostname: database
ports:
- "27017:27017"
backend:
image: "project/backend:latest"
container_name: backend
hostname: backend
environment:
- NODE_ENV=production
- DATABASE_HOST=database
ports:
- "8080:8080"
depends_on:
- database
tty: true
connector:
image: "project/connector:latest"
container_name: connector
hostname: connector
environment:
- NODE_ENV=production
- BACKEND_HOST=backend
depends_on:
- backend
# net: host
network_mode: "host"
tty: true
The problem with the yaml file above is, that the connector can not resolve “backend”.