Running Jupyter With Only Docker Containers
By: Charles Samuel R
Tags: Jupyter, Jupyter Notebook, Docker, Data Science, Anaconda

The notebook templates that are available in Jupyter Docker Stacks are:

base-notebook — Small baseline environment

datascience-notebook — Environment with Data Science packages

minimal-notebook — Minimalistic Environment

pyspark-notebook — Environment with PySpark

all-spark-notebook — Environment for Scala, R, and so on

r-notebook(R support is there, don’t fret) — R environment

scipy-notebook — Environment for Scipy

tensorflow-notebook — Tensorflow Environment

Enclosed in the list are the links to the Docker images of each of the notebook environments if you want to check them out.

All of these notebook templates will be available at Docker Hub ready to pull for each necessity.

I will be pulling the datascience notebook and we can compare them to a small basic Anaconda environment.

To pull a notebook all you have to do is use the following command:

$ sudo docker run -p 5000:8888 jupyter/datascience-notebook:9b06df75e445

I run Docker without root hence the sudo. What this command does is runs the Docker Image of the Data Science Notebook present in the ID 9b06df75e445 and runs the Jupyter Notebook on the port 5000 instead of the usual port number(I had the Anaconda environment running simultaneously). The output in the terminal is as follows:

Image by Author

I already pulled the image from Docker Hub. If not available, it will be downloaded and then served up for you.

So, now when you go to the link that is specified, you see a Jupyter notebook server that would look something like this:

Image by Author

Here you can create your notebooks and they will be saved here next time you load them. When you click on new you might be seeing this:

All 3 Languages for DS is there

When you pip freeze in a Python notebook, you will find the following requirements:

alembic==0.9.9

asn1crypto==0.24.0

async-generator==1.10

attrs==18.2.0

backcall==0.1.0

beautifulsoup4==4.6.3

bleach==3.0.2

bokeh==0.13.0

certifi==2018.11.29

cffi==1.11.5

chardet==3.0.4

cloudpickle==0.5.6

conda==4.5.12

cryptography==2.3.1

cryptography-vectors==2.3.1

cycler==0.10.0

Cython==0.28.5

cytoolz==0.9.0.1

dask==1.0.0

decorator==4.3.0

dill==0.2.8.2

entrypoints==0.2.3

fastcache==1.0.2

gmpy2==2.0.8

h5py==2.7.1

idna==2.8

imageio==2.4.1

ipykernel==5.1.0

ipython==7.2.0

ipython-genutils==0.2.0

ipywidgets==7.2.1

jedi==0.13.2

Jinja2==2.10

jsonschema==3.0.0a3

jupyter-client==5.2.4

jupyter-core==4.4.0

jupyterhub==0.9.4

jupyterlab==0.35.4

jupyterlab-server==0.2.0

kiwisolver==1.0.1

llvmlite==0.23.0

Mako==1.0.7

MarkupSafe==1.1.0

matplotlib==2.2.3

mistune==0.8.4

mpmath==1.1.0

nbconvert==5.3.1

nbformat==4.4.0

networkx==2.2

notebook==5.7.2

numba==0.38.1

numexpr==2.6.9

numpy==1.13.3

olefile==0.46

packaging==18.0

pamela==0.3.0

pandas==0.23.4

pandocfilters==1.4.2

parso==0.3.1

patsy==0.5.1

pexpect==4.6.0

pickleshare==0.7.5

Pillow==5.3.0

prometheus-client==0.5.0

prompt-toolkit==2.0.7

protobuf==3.6.1

ptyprocess==0.6.0

pycosat==0.6.3

pycparser==2.19

pycurl==7.43.0.2

Pygments==2.3.1

pyOpenSSL==18.0.0

pyparsing==2.3.0

pyrsistent==0.14.8

PySocks==1.6.8

python-dateutil==2.7.5

python-editor==1.0.3

python-oauth2==1.0.1

pytz==2018.7

PyWavelets==1.0.1

PyYAML==3.13

pyzmq==17.1.2

requests==2.21.0

rpy2==2.8.5

ruamel-yaml==0.15.71

scikit-image==0.14.1

scikit-learn==0.20.2

scipy==1.1.0

seaborn==0.9.0

Send2Trash==1.5.0

singledispatch==3.4.0.3

six==1.12.0

SQLAlchemy==1.2.15

statsmodels==0.9.0

sympy==1.1.1

terminado==0.8.1

testpath==0.4.2

toolz==0.9.0

tornado==5.1.1

traitlets==4.3.2

urllib3==1.24.1

vincent==0.4.4

wcwidth==0.1.7

webencodings==0.5.1

widgetsnbextension==3.2.1

xlrd==1.2.0

And what did I get in the Anaconda Environment?

Take a look at it yourself:

alabaster==0.7.12

anaconda-client==1.7.2

anaconda-project==0.8.3

argh==0.26.2

asn1crypto==1.3.0

astroid @ file:///tmp/build/80754af9/astroid_1592495912941/work

astropy==4.0.1.post1

atomicwrites==1.4.0

attrs==19.3.0

autopep8 @ file:///tmp/build/80754af9/autopep8_1592412889138/work

Babel==2.8.0

backcall==0.2.0

backports.shutil-get-terminal-size==1.0.0

beautifulsoup4==4.9.1

bitarray @ file:///tmp/build/80754af9/bitarray_1594753876414/work

bkcharts==0.2

bleach==3.1.5

bokeh @ file:///tmp/build/80754af9/bokeh_1593187602660/work

boto==2.49.0

Bottleneck==1.3.2

brotlipy==0.7.0

certifi==2020.6.20

cffi==1.14.0

chardet==3.0.4

click==7.1.2

cloudpickle @ file:///tmp/build/80754af9/cloudpickle_1594141588948/work

clyent==1.2.2

colorama==0.4.3

contextlib2==0.6.0.post1

cryptography==2.9.2

cycler==0.10.0

Cython @ file:///tmp/build/80754af9/cython_1594831566883/work

cytoolz==0.10.1

dask @ file:///tmp/build/80754af9/dask-core_1594156306305/work

decorator==4.4.2

defusedxml==0.6.0

diff-match-patch @ file:///tmp/build/80754af9/diff-match-patch_1594828741838/work

distributed @ file:///tmp/build/80754af9/distributed_1594750293818/work

docutils==0.16

entrypoints==0.3

et-xmlfile==1.0.1

fastcache==1.1.0

filelock==3.0.12

flake8==3.8.3

Flask==1.1.2

fsspec==0.7.4

future==0.18.2

gevent @ file:///tmp/build/80754af9/gevent_1593009537125/work

glob2==0.7

gmpy2==2.0.8

greenlet==0.4.16

h5py==2.10.0

HeapDict==1.0.1

html5lib @ file:///tmp/build/80754af9/html5lib_1593446221756/work

idna @ file:///tmp/build/80754af9/idna_1593446292537/work

imageio @ file:///tmp/build/80754af9/imageio_1594161405741/work

imagesize==1.2.0

importlib-metadata @ file:///tmp/build/80754af9/importlib-metadata_1593446406207/work

intervaltree @ file:///tmp/build/80754af9/intervaltree_1594361675072/work

ipykernel @ file:///tmp/build/80754af9/ipykernel_1594753368510/work/dist/ipykernel-5.3.2-py3-none-any.whl

ipython @ file:///tmp/build/80754af9/ipython_1593447377063/work

ipython-genutils==0.2.0

ipywidgets==7.5.1

isort==4.3.21

itsdangerous==1.1.0

jdcal==1.4.1

jedi @ file:///tmp/build/80754af9/jedi_1592841866100/work

jeepney==0.4.3

Jinja2==2.11.2

joblib @ file:///tmp/build/80754af9/joblib_1594236160679/work

json5==0.9.5

jsonschema==3.2.0

jupyter==1.0.0

jupyter-client @ file:///tmp/build/80754af9/jupyter_client_1594826976318/work

jupyter-console==6.1.0

jupyter-core==4.6.3

jupyter-http-over-ws==0.0.8

jupyterlab==2.1.5

jupyterlab-server @ file:///tmp/build/80754af9/jupyterlab_server_1594164409481/work

keyring @ file:///tmp/build/80754af9/keyring_1593109721646/work

kiwisolver==1.2.0

lazy-object-proxy==1.4.3

libarchive-c==2.9

llvmlite==0.33.0+1.g022ab0f

locket==0.2.0

lxml @ file:///tmp/build/80754af9/lxml_1594826779415/work

MarkupSafe==1.1.1

matplotlib @ file:///tmp/build/80754af9/matplotlib-base_1592846008246/work

mccabe==0.6.1

mistune==0.8.4

mkl-fft==1.1.0

mkl-random==1.1.1

mkl-service==2.3.0

mock==4.0.2

more-itertools==8.4.0

mpmath==1.1.0

msgpack==1.0.0

multipledispatch==0.6.0

nbconvert==5.6.1

nbformat==5.0.7

networkx @ file:///tmp/build/80754af9/networkx_1594377231366/work

nltk @ file:///tmp/build/80754af9/nltk_1592496090529/work

nose==1.3.7

notebook==6.0.3

numba==0.50.1

numexpr==2.7.1

numpy==1.18.5

numpydoc @ file:///tmp/build/80754af9/numpydoc_1594166760263/work

olefile==0.46

openpyxl @ file:///tmp/build/80754af9/openpyxl_1594167385094/work

packaging==20.4

pandas @ file:///tmp/build/80754af9/pandas_1592841659173/work

pandocfilters==1.4.2

parso==0.7.0

partd==1.1.0

path==13.1.0

pathlib2==2.3.5

pathtools==0.1.2

patsy==0.5.1

pep8==1.7.1

pexpect==4.8.0

pickleshare==0.7.5

Pillow @ file:///tmp/build/80754af9/pillow_1594307295532/work

pkginfo==1.5.0.1

pluggy==0.13.1

ply==3.11

prometheus-client==0.8.0

prompt-toolkit==3.0.5

psutil==5.7.0

ptyprocess==0.6.0

py @ file:///tmp/build/80754af9/py_1593446248552/work

pycodestyle==2.6.0

pycosat==0.6.3

pycparser @ file:///tmp/build/80754af9/pycparser_1594388511720/work

pycurl==7.43.0.5

pydocstyle @ file:///tmp/build/80754af9/pydocstyle_1592848020240/work

pyflakes==2.2.0

Pygments==2.6.1

pylint @ file:///tmp/build/80754af9/pylint_1592496053748/work

pyodbc===4.0.0-unsupported

pyOpenSSL @ file:///tmp/build/80754af9/pyopenssl_1594392929924/work

pyparsing==2.4.7

pyrsistent==0.16.0

PySocks==1.7.1

pytest==5.4.3

python-dateutil==2.8.1

python-jsonrpc-server @ file:///tmp/build/80754af9/python-jsonrpc-server_1594397536060/work

python-language-server @ file:///tmp/build/80754af9/python-language-server_1594161909948/work

pytz==2020.1

PyWavelets==1.1.1

pyxdg==0.26

PyYAML==5.3.1

pyzmq==19.0.1

QDarkStyle==2.8.1

QtAwesome==0.7.2

qtconsole @ file:///tmp/build/80754af9/qtconsole_1592848611704/work

QtPy==1.9.0

regex @ file:///tmp/build/80754af9/regex_1593435547652/work

requests @ file:///tmp/build/80754af9/requests_1592841827918/work

rope==0.17.0

Rtree==0.9.4

ruamel-yaml==0.15.87

scikit-image==0.16.2

scikit-learn @ file:///tmp/build/80754af9/scikit-learn_1592502866053/work

scipy @ file:///tmp/build/80754af9/scipy_1592930511789/work

seaborn==0.10.1

SecretStorage==3.1.2

Send2Trash==1.5.0

simplegeneric==0.8.1

singledispatch==3.4.0.3

sip==4.19.13

six==1.15.0

snowballstemmer==2.0.0

sortedcollections==1.2.1

sortedcontainers==2.2.2

soupsieve==2.0.1

Sphinx @ file:///tmp/build/80754af9/sphinx_1594223420021/work

sphinxcontrib-applehelp==1.0.2

sphinxcontrib-devhelp==1.0.2

sphinxcontrib-htmlhelp==1.0.3

sphinxcontrib-jsmath==1.0.1

sphinxcontrib-qthelp==1.0.3

sphinxcontrib-serializinghtml==1.1.4

sphinxcontrib-websupport @ file:///tmp/build/80754af9/sphinxcontrib-websupport_1593446360927/work

spyder @ file:///tmp/build/80754af9/spyder_1594832131358/work

spyder-kernels @ file:///tmp/build/80754af9/spyder-kernels_1594751551963/work

SQLAlchemy @ file:///tmp/build/80754af9/sqlalchemy_1593446299926/work

statsmodels==0.11.1

sympy @ file:///tmp/build/80754af9/sympy_1594236545715/work

tables==3.6.1

tblib==1.6.0

terminado==0.8.3

testpath==0.4.4

threadpoolctl @ file:///tmp/tmp9twdgx9k/threadpoolctl-2.1.0-py3-none-any.whl

toml @ file:///tmp/build/80754af9/toml_1592853716807/work

toolz==0.10.0

tornado==6.0.4

tqdm @ file:///tmp/build/80754af9/tqdm_1593446365756/work

traitlets==4.3.3

typing-extensions @ file:///tmp/build/80754af9/typing_extensions_1592847887441/work

ujson==1.35

unicodecsv==0.14.1

urllib3==1.25.9

watchdog @ file:///tmp/build/80754af9/watchdog_1593447344699/work

wcwidth @ file:///tmp/build/80754af9/wcwidth_1593447189090/work

webencodings==0.5.1

Werkzeug==1.0.1

widgetsnbextension==3.5.1

wrapt==1.11.2

wurlitzer @ file:///tmp/build/80754af9/wurlitzer_1594753850195/work

xlrd==1.2.0

XlsxWriter==1.2.9

xlwt==1.3.0

yapf @ file:///tmp/build/80754af9/yapf_1593528177422/work

zict==2.0.0

zipp==3.1.0

zope.event==4.4

zope.interface==4.7.1

One pretty obvious thing you can see is that the Data Science notebook is more specific whereas in our Anaconda Environment we need the unnecessary number of packages which might not even be used that much. A big plus is that we have even got the 3 languages used in DS(Data Science) as well (Maybe this could be the time I finally start learning Julia or even R).

The environment can be saved and loaded again if you specify the command:

$ docker run --rm -p 10000:8888 -e JUPYTER_ENABLE_LAB=yes -v "$PWD":/home/your_name/work jupyter/datascience-notebook:9b06df75e445

This makes sure that Docker does not destroy the container and saves your work as well.

That is it for this post. Thank you so much for reading 😄

Source Code:

Documentation:

If you’re interested in alternatives you can check these out too: