-
Notifications
You must be signed in to change notification settings - Fork 42
/
start-container.sh
executable file
·33 lines (26 loc) · 1.06 KB
/
start-container.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/bash
# run N slave containers
tag=$1
N=$2
if [ $# != 2 ]
then
echo "Set first parametar as image version tag(e.g. 0.1) and second as number of nodes"
exit 1
fi
# delete old master container and start new master container
sudo docker rm -f master.krejcmat.com &> /dev/null
echo "start master container..."
sudo docker run -d -t --restart=always --dns 127.0.0.1 -P --name master.krejcmat.com -h master.krejcmat.com -w /root krejcmat/hadoop-hbase-master:$tag&> /dev/null
# get the IP address of master container
FIRST_IP=$(docker inspect --format="{{.NetworkSettings.IPAddress}}" master.krejcmat.com)
# delete old slave containers and start new slave containers
i=1
while [ $i -le $N ]
do
sudo docker rm -f slave$i.krejcmat.com &> /dev/null
echo "start slave$i container..."
sudo docker run -d -t --restart=always --dns 127.0.0.1 -P --name slave$i.krejcmat.com -h slave$i.krejcmat.com -e JOIN_IP=$FIRST_IP krejcmat/hadoop-hbase-slave:$tag &> /dev/null
((i++))
done
# create a new Bash session in the master container
sudo docker exec -it master.krejcmat.com bash