用PIPEWORK为docker容器配置独立IP
官方网站:https://github.com/jpetazzo/pipework宿主环境:centos7安装pipework# wget https://github.com/jpetazzo/pipework/archive/master.zip# unzip master.zip # cp pipework-master/pipework /usr/local/
·
官方网站:https://github.com/jpetazzo/pipework
宿主环境:centos7
安装pipework
# wget https://github.com/jpetazzo/pipework/archive/master.zip
# unzip master.zip
# cp pipework-master/pipework /usr/local/bin/
# chmod +x /usr/local/bin/pipework
给宿主机创建网桥
[root@localhost ~]# vi /etc/sysconfig/network-scripts/ifcfg-eno16777736
TYPE=Ethernet
#BOOTPROTO=static
#IPADDR=172.16.146.116
#NETMASK=255.255.255.0
#GATEWAY=172.16.146.1
#DNS1=8.8.8.8
#DNS2=192.168.252.3
BOOTPROTO="none"
DEFROUTE="yes"
PEERDNS="yes"
PEERROUTES="yes"
NAME=eno16777736
ONBOOT=yes
BRIDGE="br0"
~
设置物理网卡桥接到网桥
[root@localhost ~]# vi /etc/sysconfig/network-scripts/ifcfg-br0
TYPE="Bridge"
BOOTPROTO=static
IPADDR=172.16.146.116
NETMASK=255.255.255.0
GATEWAY=172.16.146.1
PREFIX=24
DNS1=8.8.8.8
DNS2=192.168.252.3
NAME=br0
ONBOOT=yes
DEVICE=br0
运行一个容器:
[root@localhost ~]# pipework br0 $(docker run -d -it -p 80:80 --name testduliip centos) 172.16.146.113/24@172.16.146.1
再运行一个:
[root@localhost ~]# pipework br0 $(docker run -d -it --net=none --name testduliip01 centos) 172.16.146.112/24@172.16.146.1
重启容器后需要再次指定:
pipework br0 testduliip 172.16.146.113/24@172.16.146.1
pipework br0 testduliip01 172.16.146.112/24@172.16.146.1
宿主环境:centos7
安装pipework
# wget https://github.com/jpetazzo/pipework/archive/master.zip
# unzip master.zip
# cp pipework-master/pipework /usr/local/bin/
# chmod +x /usr/local/bin/pipework
给宿主机创建网桥
[root@localhost ~]# vi /etc/sysconfig/network-scripts/ifcfg-eno16777736
TYPE=Ethernet
#BOOTPROTO=static
#IPADDR=172.16.146.116
#NETMASK=255.255.255.0
#GATEWAY=172.16.146.1
#DNS1=8.8.8.8
#DNS2=192.168.252.3
BOOTPROTO="none"
DEFROUTE="yes"
PEERDNS="yes"
PEERROUTES="yes"
NAME=eno16777736
ONBOOT=yes
BRIDGE="br0"
~
设置物理网卡桥接到网桥
[root@localhost ~]# vi /etc/sysconfig/network-scripts/ifcfg-br0
TYPE="Bridge"
BOOTPROTO=static
IPADDR=172.16.146.116
NETMASK=255.255.255.0
GATEWAY=172.16.146.1
PREFIX=24
DNS1=8.8.8.8
DNS2=192.168.252.3
NAME=br0
ONBOOT=yes
DEVICE=br0
运行一个容器:
[root@localhost ~]# pipework br0 $(docker run -d -it -p 80:80 --name testduliip centos) 172.16.146.113/24@172.16.146.1
再运行一个:
[root@localhost ~]# pipework br0 $(docker run -d -it --net=none --name testduliip01 centos) 172.16.146.112/24@172.16.146.1
重启容器后需要再次指定:
pipework br0 testduliip 172.16.146.113/24@172.16.146.1
pipework br0 testduliip01 172.16.146.112/24@172.16.146.1
更多推荐
已为社区贡献1条内容
所有评论(0)