/DataScienceNotebook

A general purpose clean example on how to construct R and Python notebooks using Docker

Primary LanguageDockerfileMIT LicenseMIT

DataScienceNotebook

Example on how to construct R and Python notebooks within docker, ensuring a clean working environment without disturbing any Python or R on the host system.

Software Requirements

The DataScienceNotebook has been tested in a Linux-based OS x64_86 system (tested on Ubuntu 18.04) and a MacOS (13.x) apple-silicon system. It is fully containerized in docker it should, in theory, be possible to run it on any other OS.

Please ensure you have the following software installed on your machine:

docker

You can get docker here

(Optional) Before Running the notebook

Customized R version and/or R packages If you require a specific R version and/or R packages, be sure to uncomment the R component of the Dockerfile

Customized python packages If you require specific packages installed in Python make sure you edit the requirements.txt file and list required packages.

Running the notebook

First, make sure you are in the root directory of this github folder.

  1. Building the custom docker enironment for this jupyter notebook.
docker build -t dsn-image .

TROUBLESHOOTING: Explicitly re-pull the 'latest' image and do a complete rebuild without using the caching: docker build --pull --no-cache -t dsn-image .

  1. To start the jupyter notebook:
docker run -d -p 8888:8888 -v $(pwd):/home/jovyan/work --name dsn-container --platform linux/x86_64 dsn-image

TROUBLESHOOTING: The -p 8888:8888 specified host:docker port assignment. If 8888 is already in use in the host, feel free to change. Make sure you change the port on localhost in the command at step 3 as well

  1. Next, you can access the notebook on your machine by clicking on the link generated by the following command:
docker exec -it dsn-container bash -c 'jupyter lab list' | grep http | cut -f1 -d ' ' | sed 's/\/\/.*:8888/\/\/localhost:8888/'
  1. (Alternative), use the following command to automatically open the generated link in your default browser
docker exec -it dsn-container bash -c 'jupyter lab list' | grep http | cut -f1 -d ' ' | sed 's/\/\/.*:8888/\/\/localhost:8888/' | xargs open

Shutting the jupyter notebook down:

docker stop dsn-container && docker rm dsn-container