forked from kiwenlau/hadoop-cluster-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-image.sh
executable file
·71 lines (59 loc) · 1.32 KB
/
build-image.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/bin/bash
image=$1
tag="0.1.0"
if [ $# = 0 ]
then
echo "Please use image name as the argument!"
exit 1
fi
# founction for delete images
function docker_rmi()
{
echo -e "\n\nsudo docker rmi kiwenlau/$1:$tag"
sudo docker rmi kiwenlau/$1:$tag
}
# founction for build images
function docker_build()
{
cd $1
echo -e "\n\nsudo docker build -t kiwenlau/$1:$tag ."
/usr/bin/time -f "real %e" sudo docker build -t kiwenlau/$1:$tag .
cd ..
}
echo -e "\ndocker rm -f slave1 slave2 master"
sudo docker rm -f slave1 slave2 master
sudo docker images >images.txt
if [ $image == "serf-dnsmasq" ]
then
docker_rmi hadoop-master
docker_rmi hadoop-slave
docker_rmi hadoop-base
docker_rmi serf-dnsmasq
docker_build serf-dnsmasq
docker_build hadoop-base
docker_build hadoop-master
docker_build hadoop-slave
elif [ $image == "hadoop-base" ]
then
docker_rmi hadoop-master
docker_rmi hadoop-slave
docker_rmi hadoop-base
docker_build hadoop-base
docker_build hadoop-master
docker_build hadoop-slave
elif [ $image == "hadoop-master" ]
then
docker_rmi hadoop-master
docker_build hadoop-master
elif [ $image == "hadoop-slave" ]
then
docker_rmi hadoop-slave
docker_build hadoop-slave
else
echo "The image name is wrong!"
fi
echo -e "\nimages before build"
cat images.txt
rm images.txt
echo -e "\nimages after build"
sudo docker images