-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstart_notebook.sh
31 lines (26 loc) · 912 Bytes
/
start_notebook.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
image=2019-weightwatcher-on-gleams
platform=jupyter
if [ $platform = "jupyter" ]; then
port=8888
home_dir=/home/jovyan/work
else
port=8787
home_dir=/home/rstudio
fi
docker build -t $image .
image_id=$(docker run -d --rm -p 80:$port -v "$(pwd):$home_dir" $image)
kill_container_script=kill-container-${image_id}.sh
echo '#!/bin/bash' > $kill_container_script
echo "docker kill $image_id" >> $kill_container_script
echo "Waiting for container to start..."
sleep 5
echo ""
echo "Notebook server running in container $image_id"
echo "Use 'bash kill-container-${image_id}.sh' to kill it."
echo ""
url_attributes=$(docker container logs $image_id --tail 1 2>&1 | grep -o \?.*)
token=$(echo $url_attributes | grep -o token=.* | cut -d"=" -f2)
echo "If the notebook did not open automatically, point your browser to http://127.0.0.1$url_attributes"
echo "Login with:"
echo "token: $token"
open http://127.0.0.1