Wednesday 19 November 2014

docker networking with hack part1

I found the easy way of having multiple container running on the same host, bind with the host IP, then assign multiple IP the same interface of the host.

1. How do I bind multiple IP to the same interface:

amund@prod-docker-app01:~$ cat /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static
address 172.22.19.75
netmask 255.255.255.0
network 172.22.19.0
broadcast 172.22.19.255
gateway 172.22.19.1
# dns-* options are implemented by the resolvconf package, if installed
dns-nameservers 172.17.0.10 172.17.0.14 172.27.2.20
dns-search example.com example.net example.in

# bind-ed one assigned IP
auto eth0:0
iface eth0:0 inet static
        address 172.22.19.76
        netmask 255.255.255.0
        network 172.22.19.0
        broadcast 172.22.19.255
        gateway 172.22.19.1
        # dns-* options are implemented by the resolvconf package, if installed
dns-nameservers 172.17.0.10 172.17.0.14 172.27.2.20
dns-search example.com example.net example.in

# bind-ed second assigned IP
auto eth0:1
iface eth0:1 inet static
        address 172.22.19.77
        netmask 255.255.255.0
        network 172.22.19.0
        broadcast 172.22.19.255
        gateway 172.22.19.1
        # dns-* options are implemented by the resolvconf package, if installed
dns-nameservers 172.17.0.10 172.17.0.14 172.27.2.20
dns-search example.com example.net example.in

# bind-ed thired assigned IP
auto eth0:2
iface eth0:2 inet static
        address 172.22.19.78
        netmask 255.255.255.0
        network 172.22.19.0
        broadcast 172.22.19.255
        gateway 172.22.19.1
        # dns-* options are implemented by the resolvconf package, if installed
dns-nameservers 172.17.0.10 172.17.0.14 172.27.2.20
dns-search example.com example.net example.in

2. If you are using remote host, good to reboot once and check your network update.


No comments:

Post a Comment