You really want to save your notebooks on your hard drive and not in the container. This is what I do.
~/.bash_profile I have the following
alias (btw, I’m on macOS):
alias jupyter='docker run --rm -p 8888:8888 -v $(PWD):/opt/notebooks continuumio/anaconda3 /bin/bash -c "/opt/conda/bin/jupyter notebook --ip=0.0.0.0 --port=8888 --notebook-dir=/opt/notebooks --allow-root --no-browser"'
Whenever I need to use Jupyter I just
cd into the folder that I want to save my notebook and issue the command:
That’s it! Jupyter will run in a Docker container and it displays the URL that I need to use to access it. The output looks something like this:
[I 18:11:40.415 NotebookApp] Writing notebook server cookie secret to /root/.local/share/jupyter/runtime/notebook_cookie_secret
[I 18:11:40.617 NotebookApp] JupyterLab extension loaded from /opt/conda/lib/python3.7/site-packages/jupyterlab
[I 18:11:40.617 NotebookApp] JupyterLab application directory is /opt/conda/share/jupyter/lab
[I 18:11:40.619 NotebookApp] Serving notebooks from local directory: /opt/notebooks
[I 18:11:40.619 NotebookApp] The Jupyter Notebook is running at:
[I 18:11:40.619 NotebookApp] http://7e042f5cd84d:8888/?token=e907fe10763ec8d8c8283fbf930381123df2791b1f6588b2
[I 18:11:40.619 NotebookApp] or http://127.0.0.1:8888/?token=e907fe10763ec8d8c8283fbf930381123df2791b1f6588b2
[I 18:11:40.619 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 18:11:40.622 NotebookApp]
To access the notebook, open this file in a browser:
Or copy and paste one of these URLs:
Then I cut and paste the last URL into my browser and I’m all set. All of my notebooks are saved on my hard drive. I can safely update the Docker images with the latest version of Jupyter and know that all of my notebooks are safe on my local hard drive. I find this to be the best workflow.