This repository has been archived by the owner on Feb 10, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.sh
executable file
·51 lines (49 loc) · 1.47 KB
/
run.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
#!/usr/bin/env bash
function usage {
echo "Usage: run.sh [command]"
echo
echo "Commands:"
echo
echo " bash:"
echo " starts a bash shell"
echo
echo " jupyter:"
echo " starts jupyter notebook"
echo " args:"
echo " /path/to/notebooks"
echo " port_number (default 8888)"
echo
echo " clean:"
echo " removes pcmdi docker images"
echo " args":
echo " -f: forces removal of both running and exited containers"
}
case "$1" in
bash)
docker run -it --init pcmdi bash
;;
jupyter)
if [ -z "$2" ] ; then
echo "Missing the path to notebooks"
exit 1
fi
WORKSPACE=$(readlink -f "$2")
echo "Notebooks will be saved in ${WORKSPACE}"
echo "Open http://localhost:${3:-8888} to access Jupyter"
docker run -it -v ${WORKSPACE}:/opt/notebooks -p ${3:-8888}:8888 pcmdi bash -c ". activate pcmdi && jupyter notebook --notebook-dir=/opt/notebooks --ip='*' --port=8888 --no-browser --allow-root --NotebookApp.token=''"
;;
clean)
if [ "$2" == "-f" ] ; then
FORCE="-f"
else
FILTER="--filter status=exited"
fi
for c in $(docker ps -a ${FILTER} | awk '{ print $1,$2 }' | grep pcmdi | awk '{ print $1 }')
do
docker container rm ${FORCE} $c
done
;;
*)
usage
exit 1
esac