1

I am unable to open Jupyter Notebooks in the web browser when I use a Docker image using the docker run command. I get the following error:

This site can’t be reached. The webpage at http://127.0.0.1:8888/?token=8543b16468608a7d26b8183256a97ebc3df41bf8838a3729 might be temporarily down or it may have moved permanently to a new web address. ERR_SOCKET_NOT_CONNECTED

So far, I noticed it doesn't work for me from Jupyter and Tensorflow docker images. However, if I use the same image tags in a Dockerfile and use the docker-compose command everything works fine. I also tried building the image and then running the image but that didn't work either. I build from the Dockerfile:

docker build -t notebook .

and then do

docker run --rm -p 8888:8888 -v $(pwd):/home/jovyan/work notebook

It seems that only using docker-compose works for me when trying to use Jupyter Notebook. Anybody know why that is?

OS: Ubuntu 20.04 LTS

Computer model HP ZBook

Docker run command and output (doesn't work)

docker run --rm -p 8888:8888 -v $(pwd):/home/jovyan/work jupyter/minimal-notebook:notebook-6.4.3

The output from the terminal

WARN: Jupyter Notebook deprecation notice https://github.com/jupyter/docker-stacks#jupyter-notebook-deprecation-notice.
Executing the command: jupyter notebook
[I 14:17:21.359 NotebookApp] Writing notebook server cookie secret to /home/jovyan/.local/share/jupyter/runtime/notebook_cookie_secret
[W 2021-08-31 14:17:21.823 LabApp] 'ip' has moved from NotebookApp to ServerApp. This config will be passed to ServerApp. Be sure to update your config before our next release.
[W 2021-08-31 14:17:21.823 LabApp] 'port' has moved from NotebookApp to ServerApp. This config will be passed to ServerApp. Be sure to update your config before our next release.
[W 2021-08-31 14:17:21.823 LabApp] 'port' has moved from NotebookApp to ServerApp. This config will be passed to ServerApp. Be sure to update your config before our next release.
[W 2021-08-31 14:17:21.823 LabApp] 'port' has moved from NotebookApp to ServerApp. This config will be passed to ServerApp. Be sure to update your config before our next release.
[I 2021-08-31 14:17:21.830 LabApp] JupyterLab extension loaded from /opt/conda/lib/python3.9/site-packages/jupyterlab
[I 2021-08-31 14:17:21.831 LabApp] JupyterLab application directory is /opt/conda/share/jupyter/lab
[I 14:17:21.835 NotebookApp] Serving notebooks from local directory: /home/jovyan
[I 14:17:21.835 NotebookApp] Jupyter Notebook 6.4.3 is running at:
[I 14:17:21.835 NotebookApp] http://7f3100bc5b0b:8888/?token=1eee2aee8a3fcda212f056af931a14b7dd5490846627c122
[I 14:17:21.835 NotebookApp]  or http://127.0.0.1:8888/?token=1eee2aee8a3fcda212f056af931a14b7dd5490846627c122
[I 14:17:21.835 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 14:17:21.838 NotebookApp] 
    
    To access the notebook, open this file in a browser:
        file:///home/jovyan/.local/share/jupyter/runtime/nbserver-8-open.html
    Or copy and paste one of these URLs:
        http://7f3100bc5b0b:8888/?token=1eee2aee8a3fcda212f056af931a14b7dd5490846627c122
     or http://127.0.0.1:8888/?token=1eee2aee8a3fcda212f056af931a14b7dd5490846627c122

When I open the browser with the link I get

This site can’t be reached The webpage at http://127.0.0.1:8888/?token=8543b16468608a7d26b8183256a97ebc3df41bf8838a3729 might be temporarily down or it may have moved permanently to a new web address.
    ERR_SOCKET_NOT_CONNECTED

Docker compose command and output (works)

I have a docker-compose.yml file with

version: "3.2"

services:
  jupyter:  # you can change this "jupyter" service to whatever you want.
    build: 
      context: ./docker-folder  # this is where the build directory is aka. Dockerfile.
    image: compose-test
    volumes:
      - "./:/home/jovyan"
    ports:
     - "8888:8888"

A Dockerfile with the following contents in a folder called docker-folder

FROM jupyter/minimal-notebook:notebook-6.4.3

In the terminal, I use the following commands

docker-compose build && docker-compose up

The jupyter notebook opens in the web browser with no problems. The output in the terminal is the following

Creating network "desktop_default" with the default driver
Creating desktop_jupyter_1 ... done
Attaching to desktop_jupyter_1
jupyter_1  | WARN: Jupyter Notebook deprecation notice https://github.com/jupyter/docker-stacks#jupyter-notebook-deprecation-notice.
jupyter_1  | Executing the command: jupyter notebook
jupyter_1  | [W 2021-08-31 14:25:26.648 LabApp] 'ip' has moved from NotebookApp to ServerApp. This config will be passed to ServerApp. Be sure to update your config before our next release.
jupyter_1  | [W 2021-08-31 14:25:26.648 LabApp] 'port' has moved from NotebookApp to ServerApp. This config will be passed to ServerApp. Be sure to update your config before our next release.
jupyter_1  | [W 2021-08-31 14:25:26.648 LabApp] 'port' has moved from NotebookApp to ServerApp. This config will be passed to ServerApp. Be sure to update your config before our next release.
jupyter_1  | [W 2021-08-31 14:25:26.648 LabApp] 'port' has moved from NotebookApp to ServerApp. This config will be passed to ServerApp. Be sure to update your config before our next release.
jupyter_1  | [I 2021-08-31 14:25:26.654 LabApp] JupyterLab extension loaded from /opt/conda/lib/python3.9/site-packages/jupyterlab
jupyter_1  | [I 2021-08-31 14:25:26.654 LabApp] JupyterLab application directory is /opt/conda/share/jupyter/lab
jupyter_1  | [I 14:25:26.659 NotebookApp] Serving notebooks from local directory: /home/jovyan
jupyter_1  | [I 14:25:26.659 NotebookApp] Jupyter Notebook 6.4.3 is running at:
jupyter_1  | [I 14:25:26.659 NotebookApp] http://bf12dc888bfb:8888/?token=8376064cc9487deacb8182d280bb07dba6740a69cf890581
jupyter_1  | [I 14:25:26.659 NotebookApp]  or http://127.0.0.1:8888/?token=8376064cc9487deacb8182d280bb07dba6740a69cf890581
jupyter_1  | [I 14:25:26.659 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
jupyter_1  | [C 14:25:26.663 NotebookApp] 
jupyter_1  |     
jupyter_1  |     To access the notebook, open this file in a browser:
jupyter_1  |         file:///home/jovyan/.local/share/jupyter/runtime/nbserver-7-open.html
jupyter_1  |     Or copy and paste one of these URLs:
jupyter_1  |         http://bf12dc888bfb:8888/?token=8376064cc9487deacb8182d280bb07dba6740a69cf890581
jupyter_1  |      or http://127.0.0.1:8888/?token=8376064cc9487deacb8182d280bb07dba6740a69cf890581
jupyter_1  | [I 14:25:28.996 NotebookApp] 302 GET /?token=8376064cc9487deacb8182d280bb07dba6740a69cf890581 (172.23.0.1) 0.960000ms
jupyter_1  | /opt/conda/lib/python3.9/json/encoder.py:257: UserWarning: date_default is deprecated since jupyter_client 7.0.0. Use jupyter_client.jsonutil.json_default.
jupyter_1  |   return _iterencode(o, 0)

Then I close it all down with

docker-compose down -v

Saaru Lindestøkke
  • 2,067
  • 1
  • 25
  • 51
zipline86
  • 561
  • 2
  • 7
  • 21

1 Answers1

-1

ANSWER: Apparently, this problem is caused by my VPN (I use Express VPN but not sure if also applies to other VPNs). Everything works fine if I turn my computer on and do docker run .... If I turn my VPN on, the error will occur. Even if I turn my VPN off, the error will continue to occur. However, if I restart my computer and do the docker run command again, everything works completely fine.

I'm not sure why but I never get errors when I use my docker-compose file, it always works.

zipline86
  • 561
  • 2
  • 7
  • 21