jupyter / notebook

Jupyter Interactive Notebook
https://jupyter-notebook.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
11.6k stars 4.87k forks source link

infinite authentication loop #5286

Open OlafEichstaedt opened 4 years ago

OlafEichstaedt commented 4 years ago

I am trying to run Jupyter Lab in a Docker container on a Windows machine.

But Jupyter does not accept the token or does not allow me to register a password.

Dockerfile:

FROM jupyter/minimal-notebook
[...]

docker-compose.yml

version: '2.3'
services:
  python: 
    build:
      context: .
      dockerfile: Dockerfile
    image: python_image 
    volumes: 
      - ./notebooks:/home/jovyan/notebooks
    ports:
      - "8888:8888" 

after docker-compose up -d the container starts and the logfile shows:

[I 17:57:51.274 NotebookApp] The Jupyter Notebook is running at:
[I 17:57:51.274 NotebookApp] http://27cea0d39249:8888/?token=8b99fa26fb7e7278796c83327095b92477b3c606025f58e7
[I 17:57:51.275 NotebookApp] or http://127.0.0.1:8888/?token=8b99fa26fb7e7278796c83327095b92477b3c606025f58e7
[I 17:57:51.275 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).

When I use http://127.0.0.1:8888/?token=8b99fa26fb7e7278796c83327095b92477b3c606025f58e7 in the browser of the host computer, I get redirected to http://127.0.0.1:8888/login?next=%2Ftree%3Ftoken%3D8b99fa26fb7e7278796c83327095b92477b3c606025f58e7, and the page "Token authentication is required".

(1) entering the token (even though it was present in the URL) has no effect (fails with Invalid credentials) (2) entering token and a new password to "Setup a Password" does not work (nothing seems to happen)

Any thoughts what may be wrong?

OlafEichstaedt commented 4 years ago

After endless trials and trying a different image (continuumio/anaconda3) I stumbled upon a way to reproduce and overcome the problem.

Mapping internal port 8888 to external port 8888 does not work ... I get the authentification/login page all the time.

Mapping internal 8888 to some other port => works like charm. That means

version: '2.3'
services:
  python: 
    build:
      context: .
      dockerfile: Dockerfile
    image:  python_image
    volumes: 
      - ./notebooks:/home/jovyan/notebooks
    ports:
      - "8888:8888" 

does not let me past the login/authorization page.

version: '2.3'
services:
  python: 
    build:
      context: .
      dockerfile: Dockerfile
    image:  python_image
    volumes: 
      - ./notebooks:/home/jovyan/notebooks
    ports:
      - "9999:8888" 

does.

The container's log will say:

python_1 | [I 19:49:09.356 LabApp] The Jupyter Notebook is running at:
python_1 | [I 19:49:09.356 LabApp] http://127.0.0.1:8888/?token=[...]

and I will ask the browser to access:

http://127.0.0.1:9999/?token=[...]

and Jupyter Lab will start as expected.