Docker - Connecting to Jupyter notebook

Viewed 660

I am trying to run Jupyter notebook in docker for that I tried the command -

docker run -p 8888:8888 jupyter/scipy-notebook 

Executing the command: jupyter notebook
[I 04:19:53.460 NotebookApp] Writing notebook server cookie secret to /home/jovyan/.local/share/jupyter/runtime/notebook_cookie_secret
[I 04:19:53.856 NotebookApp] JupyterLab extension loaded from /opt/conda/lib/python3.8/site-packages/jupyterlab
[I 04:19:53.856 NotebookApp] JupyterLab application directory is /opt/conda/share/jupyter/lab
[I 04:19:53.859 NotebookApp] Serving notebooks from local directory: /home/jovyan
[I 04:19:53.859 NotebookApp] Jupyter Notebook 6.1.4 is running at:
[I 04:19:53.859 NotebookApp] http://ed93c6a6ff91:8888/?token=40c97f5c727829f0c094449618af1cad30d56a8d5c252b6c
[I 04:19:53.859 NotebookApp]  or http://127.0.0.1:8888/?token=40c97f5c727829f0c094449618af1cad30d56a8d5c252b6c
[I 04:19:53.859 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 04:19:53.861 NotebookApp] 
    
    To access the notebook, open this file in a browser:
        file:///home/jovyan/.local/share/jupyter/runtime/nbserver-6-open.html
    Or copy and paste one of these URLs:
        http://ed93c6a6ff91:8888/?token=40c97f5c727829f0c094449618af1cad30d56a8d5c252b6c
     or http://127.0.0.1:8888/?token=40c97f5c727829f0c094449618af1cad30d56a8d5c252b6c

When I try to connect to the notebook (I tried three different browsers) using the following urls -

file:///home/jovyan/.local/share/jupyter/runtime/nbserver-6-open.html 
OR  
http://ed93c6a6ff91:8888/?token=40c97f5c727829f0c094449618af1cad30d56a8d5c252b6c

I get the error the site cannot be reached instantly with error code ERR_NAME_NOT_RESOLVED, while using the url -

http://127.0.0.1:8888/?token=40c97f5c727829f0c094449618af1cad30d56a8d5c252b6c

the browser would keep trying to connect for a while and then get ERR_CONNECTION_RESET

I tried to disable my VPN. I also tried setting the no_proxy variable using export no_proxy=127.0.0.1 but I was still not able to connect to the jupyter notebook.

OS - Manjaro Linux,

docker image -

REPOSITORY               TAG                 IMAGE ID            CREATED             SIZE
jupyter/scipy-notebook   latest              b8f7562c1262        4 days ago          2.7GB

Any help or guidance on how I can troubleshoot and connect to the notebook would be much helpful.

1 Answers
Or copy and paste one of these URLs:
        http://ed93c6a6ff91:8888/?token=40c97f5c727829f0c094449618af1cad30d56a8d5c252b6c
     or http://127.0.0.1:8888/?token=40c97f5c727829f0c094449618af1cad30d56a8d5c252b6c

↑ That is your docker container IP and hostname. You need to connect using IP outside of docker container.

For example if your docker host (physical linux machine) IP is 192.168.0.100 try to access

http://192.168.0.100:8888/?token=40c97f5c727829f0c094449618af1cad30d56a8d5c252b6c

If you can't access in this case, try to set your host IP by running

docker run -p 192.168.0.100:8888:8888 jupyter/scipy-notebook 
  • Edit 1. How to check opened ports.

Try to run

sudo netstat -ntpl | grep 8888

If you will see something like

tcp6       0      0 :::8888                 :::*                    LISTEN      1234/docker-proxy

Or

tcp       0      0 0.0.0.0:8888                 0.0.0.0:*                    LISTEN      1234/docker-proxy

That means that your docker running fine and forwarding 8888 port to all local IPs (localhost including).
So if you can see open port but can't connect, firewall will be most likely cause.

Related