Docker Community Forums

Share and learn in the Docker community.

Service with more than one network that maps to a host port


(Smcdowell) #1

Given this simple docker-compose.yml:

version: “2”

services:
svc:
image: svc-image
networks:
- n1
- n2
ports:
- "80:80"
networks:
n1:
external: true
n2:
external: true

Where n1, n2 are already created bridge networks, is it well-defined how Docker will map traffic to port 80 on the host to one of the networks of this service? When I tried it was mapped to the IP address on n2.

Is it possible to control on which service interface port 80 is mapped?

Is it well-defined which internal interface (eth0, etc.) the service networks n1, n2 are represented by?