Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Terminal does not understand tab/arrow keys inside docker #2457

Closed
yebrahim opened this issue Apr 28, 2017 · 10 comments
Closed

Terminal does not understand tab/arrow keys inside docker #2457

yebrahim opened this issue Apr 28, 2017 · 10 comments

Comments

@yebrahim
Copy link

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).

@takluyver
Copy link
Member

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.

@yebrahim
Copy link
Author

yebrahim commented May 3, 2017

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

@takluyver
Copy link
Member

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

@yebrahim
Copy link
Author

yebrahim commented May 3, 2017

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?

@takluyver
Copy link
Member

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.

@yebrahim
Copy link
Author

yebrahim commented May 5, 2017

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.

@Febin-kg
Copy link

@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

@yebrahim
Copy link
Author

Have your tried using the SHELL command?

@changec
Copy link

changec commented Aug 23, 2018

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

@minrk minrk added this to the Reference milestone Sep 13, 2018
@nithincninan
Copy link

nithincninan commented Mar 9, 2019

Added environmental path

  • SHELL=/bin/bash

in windows and the issue is resolved.

Add-Sell-Env-variable

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants