-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.sh
executable file
·59 lines (48 loc) · 1.16 KB
/
utils.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
#!/bin/sh
#[in] $1 - project name, $2 - version, $3 - docker file location
#[out]
buildImage(){
docker build -t $1:$2 $3
}
#[in] $1 - project name, $2 - version, $3 - port(s) $4 - volume(s)
#[out]
startContainer(){
docker run -tid --rm -p $3 -v $4 $1:$2
ID=$(docker ps | grep "$1:$2" | awk '{print $1}')
}
#[in] $1 - project name, $2 - version
#[out] $3 - container id
getContainerId(){
ID=$(docker ps | grep "$1:$2" | awk '{print $1}')
eval "$3=$ID"
}
#[in] $1 - container id
#[out]
stopContainerById(){
docker stop $1
}
docker stop $IDr
#[in] $1 - project name, $2 - version
#[out]
isImagePresent(){
KEY="$1:$2"
NAME=$(docker images | grep "$1" | grep "$2" | awk '{print $1 ":" $2}')
echo $KEY
echo $NAME
R=1
if [ "$NAME" = "$KEY" ]; then
return 0
fi
return 1
}
#PROJECT="$1"
#VER="$2"
#HOME="$3"
#echo "The script you are running has basename `basename $0`, dirname `dirname $0`"
#BASEDIR=$(dirname "$0")
#echo "$BASEDIR"
#SCRIPT=`realpath $0`
#SCRIPTPATH=`dirname $SCRIPT`
#echo "$SCRIPTPATH"
# IMAGE=$(docker images | grep "$PROJECT" | grep "$VER" | awk '{print $1 ":" $2}')
# CONTAINER=$(docker ps | grep "$ID" | awk '{print $1}')