pipework/centos6.8/docker設置固定IP

一、安裝iproute 或者升級當前iproutegit

 rpm -Uvh https://repos.fedorapeople.org/openstack/EOL/openstack-grizzly/epel-6/iproute-2.6.32-130.el6ost.netns.2.x86_64.rpm github

二、下載pipework https://github.com/jpetazzo/pipeworkdocker

wget https://github.com/jpetazzo/pipework/archive/master.zipbash

三、解壓unzip master.zip 網絡

cp pipework到/usr/local/bin 方便執行pipework命令.net

四、ip addr add 192.168.0.109/24 dev br0; \   當前宿主機iprest

sudo ip addr del 192.168.0.109/24 dev eth0; \ 當前宿主機ipip

sudo brctl addif br0 eth0; \get

sudo ip route del default; \it

sudo ip route add default via 192.168.0.1 dev br0 當前宿主機網關ip

或直接修改network-scripts

cd /etc/sysconfig/network-scripts/;
cp ifcfg-eth0  ifcfg-br0
vi ifcfg-eth0 //增長BRIDGE=br0,刪除IPADDR,NETMASK,GATEWAY,DNS1
vi ifcfg-br0//修改DEVICE爲br0,Type爲Bridge,把eth0的網絡設置設置到這裏來
service network restart

五、啓動docker 

docker run -it --net=none --name=yourname  yourdocker /bin/bash

六、設置ip

pipework br0 yourdocker  192.168.0.xxx/24@192.168.0.1

相關文章
相關標籤/搜索