Repository navigation
Expand file tree
/
Copy pathcs2110docker.sh
More file actions
executable file
·75 lines (52 loc) · 1.91 KB
/
Copy pathcs2110docker.sh
File metadata and controls
executable file
·75 lines (52 loc) · 1.91 KB
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
72
73
74
#!/bin/bash
echo THIS IS THE NEW SCRIPT
imageName="gibrane/cs2110docker"
docker -v >/dev/null
dockerExists=$?
if [ $dockerExists != 0 ]; then
echo ERROR: Please install Docker before running this script. Refer to the CS 2110 Docker Guide.
exit
fi
docker container ls >/dev/null
dockerNotRunning=$?
if [ $dockerNotRunning != 0 ]; then
echo ERROR: Docker is not currently running. Please start Docker before running this script.
exit
fi
echo Found Docker Installation. Checking for existing containers.
existingContainers=$(docker ps -a | grep $imageName | awk '{print $1}')
echo $existingContainers
if [[ -n $existingContainers ]]; then
echo Found CS 2110 containers. Stopping and removing them.
docker stop $existingContainers >/dev/null
docker rm $existingContainers >/dev/null
else
echo No existing CS 2110 containers.
fi
if [ ! -z "$1" ] && [ $1 == "stop" ]; then
echo Successfully stopped CS 2110 containers
exit
fi
echo Pulling down most recent image of $imageName
docker pull $imageName
successfulPull=$?
if [ $successfulPull != 0 ]; then
echo ERROR: Unable to pull down the most recent image of $imageName
fi
echo Starting up new CS 2110 Docker Container:
ipAddress="$(docker-machine ip default 2>/dev/null)"
foundIp=$?;
if [ $foundIp != 0 ]; then
ipAddress="127.0.0.1";
fi
if [ "$1" == "-it" ]; then
docker run --rm -p $ipAddress:6901:6901 -p $ipAddress:5901:5901 -v "$(pwd)":/cs2110/host/ --cap-add=SYS_PTRACE --security-opt seccomp=unconfined -it --entrypoint /bin/bash gibrane/cs2110docker
else
docker run -d -p $ipAddress:6901:6901 -p $ipAddress:5901:5901 -v "$(pwd)":/cs2110/host/ --cap-add=SYS_PTRACE --security-opt seccomp=unconfined gibrane/cs2110docker
successfulRun=$?
if [ $successfulRun == 0 ]; then
echo Successfully launched CS 2110 Docker container. Please go to http://$ipAddress:6901/vnc.html to access it.
else
echo ERROR: Unable to launch CS 2110 Docker container.
fi
fi