Inside the docker-compose.yaml
I define 4 different networks:
networks:
vpp-nw:
vpp-client:
vpp-server:
vpp-db:
which use the following network addresses respectively:
172.20.0.x
172.21.0.x
172.22.0.x
172.23.0.x
One of the containers I use, connects to all 4 networks (with the same order):
# part of docker-compose.yaml
services:
my_tool:
build: ./my_tool
image: tgogos/my_tool
container_name: my_tool_docker_comp
hostname: my_tool
privileged: true
links:
- my_db
networks:
- vpp-nw
- vpp-client
- vpp-server
- vpp-db
ports:
- "8888:8888"
Is there a way to define which interface will connect to each network? For example, I would like:
eth0
to connect to the first (vpp-nw)eth1
to connect to the second (vpp-client)eth2
to connect to the third (vpp-server)eth3
to connect to the fourth (vpp-db)
Below you can see an ifconfig
output of this container. NICs seem to connect to each network in an arbitrary way every time I docker-compose down
| docker-compose up
...
eth0 Link encap:Ethernet HWaddr 02:42:ac:15:00:03
inet addr:172.21.0.3 Bcast:0.0.0.0 Mask:255.255.0.0
eth1 Link encap:Ethernet HWaddr 02:42:ac:17:00:03
inet addr:172.23.0.3 Bcast:0.0.0.0 Mask:255.255.0.0
eth2 Link encap:Ethernet HWaddr 02:42:ac:14:00:02
inet addr:172.20.0.2 Bcast:0.0.0.0 Mask:255.255.0.0
eth3 Link encap:Ethernet HWaddr 02:42:ac:16:00:03
inet addr:172.22.0.3 Bcast:0.0.0.0 Mask:255.255.0.0
Edit:
Further reading, github issues:
services
entry in yourdocker-compose.yml
? – Postprandial