黑猴子的家:docker_network.sh

在/usr/local/bin 目录下

#!/bin/bash

# 启动容器
docker start hadoop102
docker start hadoop103
docker start hadoop104

# 搭建网桥
# yum install -y bridge-utils git
# git clone https://github.com/jpetazzo/pipework.git
# cp pipework/pipework /usr/bin/
brctl addbr br0; \
ip link set dev br0 up; \
ip addr del 192.168.2.108/24 dev ens33; \
ip addr add 192.168.2.108/24 dev br0; \
brctl addif br0 ens33; \
ip route add default via 192.168.2.2 dev br0

# 睡5秒钟
sleep 5

# 给容器配置ip和网关
pipework br0 hadoop102 192.168.2.102/[email protected]
pipework br0 hadoop103 192.168.2.103/[email protected]
pipework br0 hadoop104 192.168.2.104/[email protected]

你可能感兴趣的:(黑猴子的家:docker_network.sh)