Notebook: Terminal does not understand tab/arrow keys inside docker

Created on 29 Apr 2017  路  10Comments  路  Source: jupyter/notebook

I run Jupyter inside docker. When I open a terminal window in Jupyter in this case, pressing Tab sends the cursor to the next tab stop immediately instead of performing autocomplete. Also arrow keys just print values like ^[[A instead of actually moving cursor, or showing command history.

I'm not sure if this is a Jupyter or xterm.js issue, does anyone know what's causing this? It only happens inside docker (tried both ubuntu and debian images).

Most helpful comment

The symptoms you describe sound like it's running a plain sh instead of bash. sh is the default shell if the $SHELL environment does not point to something else.

All 10 comments

The symptoms you describe sound like it's running a plain sh instead of bash. sh is the default shell if the $SHELL environment does not point to something else.

$SHELL is set to /bin/bash in the container though.

I'm not sure, then. Certainly those symptoms sound like a shell that's not using readline.

You're right actually. Even though doing echo $SHELL inside the container gives me /bin/bash, doing it inside the Jupyter terminal shows it's unassigned, thus the dumb behavior.

Can Jupyter execute export SHELL=/bin/bash for new terminals?

Jupyter is using the SHELL environment variable to pick the shell to start, so you'd need to set that before starting Jupyter. Alternatively, the NotebookApp.terminado_settings config option can override it.

Thanks for the pointer, I fixed the issue by explicitly setting the SHELL env var to /bin/bash as part of the Dockerfile.
Closing this one.

@yebrahim - Could you please tell me how you did it ?
I've set the shell ENV variable in my Dockerfile to point to /bin/bash.
However, when i docker exec -it container_id sh, it still is sh which is being loaded. The tab isn't
being recognised.
echo $SHELL does give me the output as /bin/bash.
I can alternately perform docker exec -it container_id /bin/bash, but I'm trying to default the shell to /bin/bash

Have your tried using the SHELL command?

I use the tensorflow/tensorflow image to open the jupyter,but the default terminal was sh.
can you tell me how to rewrite the dockerfile?

I want to open the bash terminal,thank you.

I change my Dockerfile and rebuild the image
RUN ["rm","/bin/sh"]
RUN ["ln", "-s", "/bin/bash", "/bin/sh"]
although the jupyter notebook still run sh,but it can use tab keys.
sh-4.3# ls
1_hello_tensorflow.ipynb 2_getting_started.ipynb 3_mnist_from_scratch.ipynb BUILD LICENSE
sh-4.3# cat 1_hello_tensorflow.ipynb

Added environmental path

  • [x] SHELL=/bin/bash

    in windows and the issue is resolved.

Add-Sell-Env-variable

Was this page helpful?
0 / 5 - 0 ratings