Reputation: 36131
Given the following docker-compose.yml
it is my expectation that I will find 3 network interfaces in the resulting container. But I don't know if I should expect them to be named eth0
, eth1
, eth2
, or in which order I should expect those assignments. If indeed the order is deterministic between deployments.
How do I safely use containers with multiple networks when there is - seemingly - no way to control and isolate which network my service listens on?
services:
web:
image: nginx
networks:
- first
- second
- third
networks:
first:
second:
third:
Upvotes: 1
Views: 41
Reputation: 188
I think you should define aliases for each network in service definition and reference alias in configurations to listen.
for example:
services:
web:
image: nginx
networks:
first:
aliases:
- nginx-eth0
second:
aliases:
- nginx-eth1
third:
aliases:
- nginx-eth2
networks:
first:
second:
third:
Upvotes: 1