Docker-stacks: NOTEBOOK_ARGS passed to image, but has no effect

Created on 5 Mar 2020  Â·  10Comments  Â·  Source: jupyter/docker-stacks

What docker image you are using?

jupyter/minimal-notebook

What complete docker command do you run to launch the container (omitting sensitive values)?

docker run -p 8888:8888 -e JUPYTER_ENABLE_LAB=yes -e NOTEBOOK_ARGS="--NotebookApp.token='' " jupyter/minimal-notebook

What steps do you take once the container is running to reproduce the issue?

Example:

  1. docker ps to get image id
  2. docker exec -it [container-id] bash to launch terminal within container
  3. echo $NOTEBOOK_ARGS returns --NotebookApp.token=''

What do you expect to happen?

I expect jupyter to launch without token required.

What actually happens?

It requires the token

Extra info
From what I gathered, jupyter/minimal-notebook is inherited from jupyter/base-notebook.

According to https://github.com/jupyter/docker-stacks/blob/master/base-notebook/start-singleuser.sh , $NOTEBOOK_ARGS are passed to start.sh

Then, --NotebookApp.token='' is a configuration option that should dispable notebook authentication. But it does not.

The same happens if I try passing "--NotebookApp.token=''" or "\"--NotebookApp.token=''\""

I am using Ubuntu 19.10, Docker version 18.09.9, build 1752eb3

Needs Debugging Bug

All 10 comments

Maybe try this:
docker run -p 8888:8888 -e JUPYTER_ENABLE_LAB=yes jupyter/minimal-notebook start-notebook.sh --NotebookApp.token=''

@Hugo54x thanks, however another problem now pops up.

Good news: running docker run -p 8888:8888 -e JUPYTER_ENABLE_LAB=yes jupyter/minimal-notebook start-notebook.sh --NotebookApp.token=\'\' disables authentication (as wanted)

Bad news: jupyter now does not show a link to localhost.
Executing the command: jupyter lab --NotebookApp.token='' [I 14:28:03.477 LabApp] Writing notebook server cookie secret to /home/jovyan/.local/share/jupyter/runtime/notebook_cookie_secret [W 14:28:03.714 LabApp] All authentication is disabled. Anyone who can connect to this server will be able to run code. [I 14:28:03.966 LabApp] JupyterLab extension loaded from /opt/conda/lib/python3.7/site-packages/jupyterlab [I 14:28:03.966 LabApp] JupyterLab application directory is /opt/conda/share/jupyter/lab [I 14:28:04.221 LabApp] Serving notebooks from local directory: /home/jovyan [I 14:28:04.221 LabApp] The Jupyter Notebook is running at: [I 14:28:04.221 LabApp] http://8f3a1eb5da92:8888/ [I 14:28:04.221 LabApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).

Since I am using this to distribute my notebook to users not familiar with notebooks, explaining that they should then go to localhost adds additional complexity.

I wonder if there is a way to fix jupyter output to display a local host link like [I 14:28:04.221 LabApp] http://localhost:8888/

The JupyterLab runs only local, if not otherwise specified.
I don't know what you wan't to do. But to tell them to start their Docker Container and then connect to localhost:8888 seems quiet simple :)
If you want to share it across an network, there are some more steps to do.

Consider this Guide: https://jupyter-notebook.readthedocs.io/en/stable/public_server.html

And there are more commands you can add to your container: https://jupyter-notebook.readthedocs.io/en/stable/config.html

Are your Users running Windows or Linux on their Systems?

I wanted to chime in and post what I've noticed today. I am unsure whether this is a new issue or related to the one in this thread.

I launch base-notebook with the following command:

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

It gives me a URL to connect to the notebook. I use the one that looks like: http://127.0.0.1:8888/?token=a4405d51cde6c...

Until today, it worked beautifully. But this morning I discovered that it now rejects the token and sends me to the "Token authentication is enabled" page. Pasting in the token doesn't work; it is rejected.

@Hugo54x I wanted jupyter to display localhost:8888 in the logs, instead of 8f3a1eb5da92:8888.

But that is not critical, thanks for your assistance!

However, while your solution worked, it seems that there is still a problem with NOTEBOOK_ARGS. Maybe it is worth investigating ?

@ddobrinskiy I think --NotebookApp.custom_display_url was added in 5.6.0 to do what you need.

https://github.com/jupyter/notebook/pull/3668/files

That said, if NOTEBOOK_ARGS aren't working, you won't be able to use it until we debug the env var problem. :)

Hello,

Maybe I've missed something however here is my understanding of the issue.
The default CMD is start-notebook.sh. So if Jupyter is not launched through the Hub, start.sh is launched directly either as jupyter lab (like in your case) or jupyter notebook.

https://github.com/jupyter/docker-stacks/blob/dc9744740e128ad7ca7c235d5f54791883c2ea69/base-notebook/start-notebook.sh#L12-L17

This is done without passing NOTEBOOK_ARGS like it is done in start-singleuser.sh

https://github.com/jupyter/docker-stacks/blob/dc9744740e128ad7ca7c235d5f54791883c2ea69/base-notebook/start-singleuser.sh#L39

Fix proposal

So we could fix this behavior by changing the start-notebook.sh:

- elif [[ ! -z "${JUPYTER_ENABLE_LAB}" ]]; then
-   . /usr/local/bin/start.sh $wrapper jupyter lab "$@"
- else
-   . /usr/local/bin/start.sh $wrapper jupyter notebook "$@"
- fi

+ elif [[ ! -z "${JUPYTER_ENABLE_LAB}" ]]; then
+   NOTEBOOK_BIN="jupyter lab"
+ else
+   NOTEBOOK_BIN="jupyter notebook"
+ fi
+ . /usr/local/bin/start.sh $wrapper $NOTEBOOK_BIN $NOTEBOOK_ARGS "$@"

It will fix the problem of taking into account NOTEBOOK_ARGS however it will not fix the fact that the URL is not correctly displayed. This behavior comes from the jupyter lab command.

$ jupyter lab --NotebookApp.token=''
# [I 20:58:47.495 LabApp] The Jupyter Notebook is running at:
# [I 20:58:47.495 LabApp] http://c8afa889cac4:8888/

$ jupyter lab
#    Or copy and paste one of these URLs:
#        http://c8afa889cac4:8888/?token=8ec0144e5c335fd4c94dd39b0f9b39425ad0bf2116834ee1
     or http://127.0.0.1:8888/?token=8ec0144e5c335fd4c94dd39b0f9b39425ad0bf2116834ee1

If you think it makes sense I can push a PR for that.

Let me know.
Best.

Hi Romain, thanks for your work on this!

The fix looks reasonable to me.

Regarding the custom url - it is a question completely unrelated to the
main issue, sorry for mixing it in.

On Wed, Mar 25, 2020 at 12:11 AM Romain notifications@github.com wrote:

Hello,

Maybe I've missed something however here is my understanding of the issue.
The default CMD is start-notebook.sh. So if Jupyter is not launched
through the Hub, start.sh is launched directly either as jupyter lab
(like in your case) or jupyter notebook.

https://github.com/jupyter/docker-stacks/blob/dc9744740e128ad7ca7c235d5f54791883c2ea69/base-notebook/start-notebook.sh#L12-L17

This is done without passing NOTEBOOK_ARGS like it is done in
start-singleuser.sh

https://github.com/jupyter/docker-stacks/blob/dc9744740e128ad7ca7c235d5f54791883c2ea69/base-notebook/start-singleuser.sh#L39
Fix proposal

So we could fix this behavior by changing the start-notebook.sh:

elif [[ ! -z "${JUPYTER_ENABLE_LAB}" ]]; then
NOTEBOOK_BIN="jupyter lab"else
NOTEBOOK_BIN="jupyter notebook"fi
. /usr/local/bin/start.sh $NOTEBOOK_BIN $NOTEBOOK_ARGS "$@"

It will fix the problem of taking into account NOTEBOOK_ARGS however it
will not fix the fact that the URL is not correctly displayed. This
behavior comes from the jupyter lab command.

$ jupyter lab --NotebookApp.token=''# [I 20:58:47.495 LabApp] The Jupyter Notebook is running at:# [I 20:58:47.495 LabApp] http://c8afa889cac4:8888/

$ jupyter lab# Or copy and paste one of these URLs:# http://c8afa889cac4:8888/?token=8ec0144e5c335fd4c94dd39b0f9b39425ad0bf2116834ee1
or http://127.0.0.1:8888/?token=8ec0144e5c335fd4c94dd39b0f9b39425ad0bf2116834ee1

If you think it makes sense I can push a PR for that.

Let me know.
Best.

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/jupyter/docker-stacks/issues/1034#issuecomment-603507044,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AHBCGEXWIFDHEONUPVH55ETRJEOZBANCNFSM4LCJTDQA
.

@ddobrinskiy Thank you for the feedback. So I will draft something and we will see.
I'm not sure of the potential impacts. We will see with the help of the community.

I keep you posted.
Best.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

akhmerov picture akhmerov  Â·  4Comments

statiksof picture statiksof  Â·  4Comments

niyazpk picture niyazpk  Â·  4Comments

codingbutstillalive picture codingbutstillalive  Â·  3Comments

jp68138743541 picture jp68138743541  Â·  4Comments