标签:
这个会由一系列的脚本构成,比如:
系统重启后,如何快速恢复服务,如何建立网桥(也可一次写入),如何在新系统上快速部署。
ADDBRIDGE
#!/bin/sh br_name=br100 brctl addbr $br_name ip addr add 192.168.X.X/D dev $br_name ip addr del 192.168.X.X/D dev eth0 ip link set $br_name up brctl addif $br_name eth0 ip route del default ip route add default via X.X.X.X dev $br_name
ADDDOCKER
#!/bin/sh br_name=br100 gateway=‘x.x.x.x‘ function run_docker() { #docker run -t -i -d --name="net_test" --net=none jdeathe/centos-ssh /bin/bash cid=$(docker run -i -t -d --name=$1 --net=none $3 /bin/bash) pid=$(docker inspect -f ‘{{.State.Pid}}‘ $cid) # set up netns mkdir -p /var/run/netns ln -s /proc/$pid/ns/net /var/run/netns/$pid # set up bridge ip link add q$pid type veth peer name r$pid brctl addif $br_name q$pid ip link set q$pid up # set up docker interface fixed_ip=$2 ip link set r$pid netns $pid ip netns exec $pid ip link set dev r$pid name eth0 ip netns exec $pid ip link set eth0 up ip netns exec $pid ip addr add $fixed_ip dev eth0 ip netns exec $pid ip route del default ip netns exec $pid ip route add default via $gateway } echo "Usage: ./docker -f demo-data" while getopts :f:h file_name do case $file_name in f) cat $OPTARG | while read line do arr_var=(${line}) run_docker ${arr_var[0]} ${arr_var[1]} ${arr_var[2]} done ;; h) echo "Usage: ./docker -f demo-data" exit 1 ;; \?) echo "Usage: ./docker -f demo-data" exit 1 ;; :) echo "Usage: ./docker -f demo-data" exit 1 ;; esac done
标签:
原文地址:http://www.cnblogs.com/aguncn/p/4295394.html