Giter Site home page Giter Site logo

lingjshi / docker-jupyter-extensible Goto Github PK

View Code? Open in Web Editor NEW

This project forked from augusto-herrmann/docker-jupyter-extensible

0.0 0.0 0.0 16 KB

A docker image for using Jupyter Notebook and Jupyter Lab, making it easy for you to extend it with the packages you need.

License: MIT License

Dockerfile 100.00%

docker-jupyter-extensible's Introduction

Extensible Docker image for Jupyter Notebook/Lab

Most tutorials for using Jupyter Notebook or Jupyter Lab end when you get Jupyter running. But, in real world applications, you will also want to set up your own system configuration parameters, install your own system and Python packages, and it may not be obvious how to do it.

This repository intends to show you an example of a Docker file where you can configure the packages you want and then build your own Docker image. Here we are going to use jupyter/scipy-notebook as a base image, but you can easily change that by editing the Dockerfile. The system configuration and packages installed are also intended as examples for you to edit.

Getting started

  1. Install Docker.

  2. Edit the Dockerfile and choose a base image. The default is:

    FROM jupyter/scipy-notebook

    which includes Pandas, NumPy and a few other things. To find a Docker image that best suits your needs, take a look at the Jupyter Docker Stacks documentation.

  3. At the following section of the Dockerfile, choose the system configuration you want to do. In this example, we configure the system locales to use both en_US.UTF-8 (English, US) and pt_BR.UTF-8 (Brazilian Portuguese) locales.

    # install the locales you want to use
    RUN set -ex \
       && sed -i 's/^# en_US.UTF-8 UTF-8$/en_US.UTF-8 UTF-8/g' /etc/locale.gen \
       && sed -i 's/^# pt_BR.UTF-8 UTF-8$/pt_BR.UTF-8 UTF-8/g' /etc/locale.gen \
       && locale-gen en_US.UTF-8 pt_BR.UTF-8 \
       && update-locale LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 \
  4. At the following section of the Dockerfile, choose the Python packages and Jupyter Lab extensions you need. For this example, we're using the data visualization tool Plotly and the map plotting package Folium.

    # install Python packages you often use
    RUN set -ex \
       && conda install --quiet --yes \
       # choose the python packages you need
       'plotly==4.14.3' \
       'folium==0.11.0' \
       && conda clean --all -f -y \
       # install jupyter lab extensions you need
       && jupyter labextension install [email protected] --no-build \
       && jupyter lab build -y \
       && jupyter lab clean -y \
       && rm -rf "/home/${NB_USER}/.cache/yarn" \
       && rm -rf "/home/${NB_USER}/.node-gyp" \
       && fix-permissions "${CONDA_DIR}" \
       && fix-permissions "/home/${NB_USER}"

    Every time you want to install a new Python package, you must edit this file again and also execute the next step.

  5. Build the Docker container with the following command:

    docker build --rm -t docker-jupyter-extensible .

    This should take a while to finish.

  6. Create a .env file so that the container can use the same user permissions as your user:

    printf "UID=$(id -u)\nGID=$(id -g)\n" > .env

    This will allow you to use the notebooks folder both inside and outside the container.

  7. Now you're set to go! Every time you want to start Jupyter, start from this step.

    Run the container with

    docker-compose up

    Note: After you have something important in the notebooks folder, I highly recommend you back it up often. The container once for me deleted the files in there automatically for some reason when I was trying to figure out how to set up those containers. YOU HAVE BEEN WARNED. I'm in no way responsible if you lose your files.

  8. Pay attention to the terminal and look for a link starting with http://127.0.0.1:8888 that also contains an access token. Open this link on a browser to use Jupyter Notebook. If you want to use Jupyter Lab, just change the URL afterwards to http://127.0.0.1:8888/lab.

docker-jupyter-extensible's People

Contributors

augusto-herrmann avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.