-
Notifications
You must be signed in to change notification settings - Fork 4
/
stop.sh
executable file
·45 lines (35 loc) · 1.43 KB
/
stop.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
#!/bin/bash
MY_DIR=$(dirname "$(readlink -f "$0")")
if [ $# -lt 1 ]; then
echo "Usage: "
echo " ${0} <container_shell_command>"
echo "e.g.: "
echo " ${0} ls -al "
fi
###################################################
#### ---- Change this only to use your own ----
###################################################
ORGANIZATION=openkbs
baseDataFolder="$HOME/data-docker"
###################################################
#### **** Container package information ****
###################################################
DOCKER_IMAGE_REPO=`echo $(basename $PWD)|tr '[:upper:]' '[:lower:]'|tr "/: " "_" `
imageTag="${ORGANIZATION}/${DOCKER_IMAGE_REPO}"
###################################################
#### ---- Mostly, you don't need change below ----
###################################################
function cleanup() {
containerID=`sudo docker ps -a|grep "${instanceName}" | awk '{print $1}'`
# if [ ! "`sudo docker ps -a|grep ${instanceName}`" == "" ]; then
if [ "${containerID}" != "" ]; then
sudo docker rm -f ${containerID}
fi
}
## -- transform '-' and space to '_'
#instanceName=`echo $(basename ${imageTag})|tr '[:upper:]' '[:lower:]'|tr "/\-: " "_"`
instanceName=`echo $(basename ${imageTag})|tr '[:upper:]' '[:lower:]'|tr "/: " "_"`
echo "---------------------------------------------"
echo "---- stop a Container for ${imageTag}"
echo "---------------------------------------------"
cleanup