I have an environment which consist of 3 application, 2 running in Windows and 1 running in Debian OS.
For testing purpose, I already build the environment in only 1 PC (running Windows 10) with VirtualBox VM (for running Debian OS).
Below is detail network configuration:
Host PC (using 2 VirtualBox Host Only Adapter):
Ethernet adapter VirtualBox Host-Only Network:
Connection-specific DNS Suffix . :
Link-local IPv6 Address . . . . . : fe80::ec0c:3c16:4f85:1a5e%12
IPv4 Address. . . . . . . . . . . : 192.168.1.11
Subnet Mask . . . . . . . . . . . : 255.255.255.0
IPv4 Address. . . . . . . . . . . : 192.168.1.12
Subnet Mask . . . . . . . . . . . : 255.255.255.0
IPv4 Address. . . . . . . . . . . : 192.168.1.13
Subnet Mask . . . . . . . . . . . : 255.255.255.0
IPv4 Address. . . . . . . . . . . : 192.168.1.14
Subnet Mask . . . . . . . . . . . : 255.255.255.0
IPv4 Address. . . . . . . . . . . : 192.168.1.15
Subnet Mask . . . . . . . . . . . : 255.255.255.0
IPv4 Address. . . . . . . . . . . : 192.168.1.21
Subnet Mask . . . . . . . . . . . : 255.255.255.0
IPv4 Address. . . . . . . . . . . : 192.168.1.22
Subnet Mask . . . . . . . . . . . : 255.255.255.0
IPv4 Address. . . . . . . . . . . : 192.168.1.23
Subnet Mask . . . . . . . . . . . : 255.255.255.0
IPv4 Address. . . . . . . . . . . : 192.168.1.24
Subnet Mask . . . . . . . . . . . : 255.255.255.0
IPv4 Address. . . . . . . . . . . : 192.168.1.25
Subnet Mask . . . . . . . . . . . : 255.255.255.0
IPv4 Address. . . . . . . . . . . : 192.168.1.26
Subnet Mask . . . . . . . . . . . : 255.255.255.0
IPv4 Address. . . . . . . . . . . : 192.168.1.31
Subnet Mask . . . . . . . . . . . : 255.255.255.0
IPv4 Address. . . . . . . . . . . : 192.168.1.32
Subnet Mask . . . . . . . . . . . : 255.255.255.0
IPv4 Address. . . . . . . . . . . : 192.168.1.33
Subnet Mask . . . . . . . . . . . : 255.255.255.0
IPv4 Address. . . . . . . . . . . : 192.168.1.34
Subnet Mask . . . . . . . . . . . : 255.255.255.0
IPv4 Address. . . . . . . . . . . : 192.168.1.123
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . :
Ethernet adapter VirtualBox Host-Only Network #2:
Connection-specific DNS Suffix . :
Link-local IPv6 Address . . . . . : fe80::5d7:813f:a9a:865d%16
IPv4 Address. . . . . . . . . . . : 192.168.1.122
Subnet Mask . . . . . . . . . . . : 255.255.255.248
Default Gateway . . . . . . . . . :
VirtualBox VM network configuration:
/etc/network/interfaces:
auto lo
iface lo inet loopback
auto eth1
iface eth1 inet static
address 192.168.1.120
netmask 255.255.255.0
gateway 192.168.1.1
auto eth2
allow-hotplug eth2
iface eth2 inet static
address 192.168.1.10
netmask 255.255.255.0
gateway 192.168.1.1
auto eth2:0
iface eth2:0 inet static
address 192.168.1.20
netmask 255.255.255.0
auto eth2:1
iface eth2:1 inet static
address 192.168.1.30
netmask 255.255.255.0
Ifconfig output:
eth0 Link encap:Ethernet HWaddr 08:00:27:a8:08:8b
inet addr:10.0.2.15 Bcast:10.0.2.255 Mask:255.255.255.0
...
eth1 Link encap:Ethernet HWaddr 08:00:27:41:27:73
inet addr:192.168.1.120 Bcast:192.168.1.255 Mask:255.255.255.0
...
eth2 Link encap:Ethernet HWaddr 08:00:27:0d:6b:54
inet addr:192.168.1.10 Bcast:192.168.1.255 Mask:255.255.255.0
...
eth2:0 Link encap:Ethernet HWaddr 08:00:27:0d:6b:54
inet addr:192.168.1.20 Bcast:192.168.1.255 Mask:255.255.255.0
...
eth2:1 Link encap:Ethernet HWaddr 08:00:27:0d:6b:54
inet addr:192.168.1.30 Bcast:192.168.1.255 Mask:255.255.255.0
...
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
...
Below is some flow of network interaction in current environment:
- App1 run in VM and create multiple socket server:
-Listening on IP 192.168.1.10, 192.168.1.20, 192.168.1.30 port 1448
-Listening on IP 192.168.1.120 port 1449 - App2 run in Host machine and create multiple connection:
-create socket server in 192.168.1.123 port 1448
-connect to socket server in VM: 192.168.1.10 port 1448 (using binding ip = 192.168.1.11)
-connect to socket server in VM: 192.168.1.20 port 1448 (using binding ip=192.168.1.12)
...
-connect to socket server in VM: 192.168.1.120 port 1449 - App3 run in Host machine and create multiple connection:
-connect to socket server 192.168.1.123 port 1448 (App2)
-connect to socket server 192.168.1.120 port 1449 (App1)
The environment is working OK now, but after read about Docker, I plan to replace VirtualBox VM with using Docker for reduce memory usage.
I successed build up an Debian image, setup library, etc...
However, I don't know how to setup network in Docker for having similar function with above VirtualBox VM configuration. Some dificult points:
- Can we create network interface similar like 'Ethernet adapter VirtualBox Host-Only Network' using Docker?
- In case we cannot create such that network interface, it is OK to remain these 2 VirtualBox Host Only Adapter in environment. But i'm not sure how to "connect" these network interface into Docker container?
- It seem impossible to assign static IP address for docker container, is this correct?
(This doesn't help: Assign static IP to Docker container) - It seem also impossible to assign multiple IP address to docker container, is it correct?
So it seem very dificult to build up above environment using Docker.
If anyone have solution that still able to build the environment using Docker, please help point out some direction.
Thank you very much!