Skip to content

Instantly share code, notes, and snippets.

@mustafaturan
Last active August 6, 2023 21:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mustafaturan/b52e034acc6c6ed61926dc06c076a5c6 to your computer and use it in GitHub Desktop.
Save mustafaturan/b52e034acc6c6ed61926dc06c076a5c6 to your computer and use it in GitHub Desktop.
Bash script to run jupyter notebook for python3 and pyspark
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#!/bin/bash
echo "Getting ip address for wlan0";
hostname=$(ip -4 addr show wlan0 | grep -oP "(?<=inet ).*(?=/)");
echo "IP: ${hostname}";
user="pi"; # give a username which will be used for image name and path, it does NOT have to be the same with login username
image="scipy";
port=10000;
name="${image}${user}";
token="${image}${user}" # update as you wish!
echo "${image}:${port}";
mkdir -p "${PWD}/${image}/${user}";
docker stop $name;
docker rm $name;
docker run --restart always -d --name $name -p $port:8888 -v "${PWD}/${image}/${user}":/home/jovyan/work "jupyter/${image}-notebook" \
start-notebook.sh --IdentityProvider.token="${token}";
echo "http://${hostname}:${port}/lab?token=${token}";
image="pyspark";
port=10001;
spark_port=1041
name="${image}${user}";
token="${image}${user}"; # update the token value as you wish!
echo "${image}:${port}";
mkdir -p "${PWD}/${image}/${user}";
docker stop $name;
docker rm $name;
docker run --restart always -d --name $name -p $port:8888 -p $spark_port:4040 -v "${PWD}/${image}/${user}":/home/jovyan/work "jupyter/${image}-notebook" \
start-notebook.sh --IdentityProvider.token="${token}";
echo "http://${hostname}:${port}/lab?token=${token}";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment