command-line-interfacedocker-desktop

How to permanently enable arrow keys for Docker Desktop CLI?


I am able to start a command line interface (CLI) for a distinct docker container from within Docker Desktop:

enter image description here

If I press an arrow key inside the console window, strange character codes are shown, e.g. if I press the up key, instead of showing the last command, the characters "^[[A" are shown:

enter image description here

=> How can I permanently adapt the shell command?

I tried to set SHELL=/bin/bash in the system environment variables to use bash instead sh but that did not help.

Related:

docker exec bash in windows - keyboard arrow keys don't work

https://github.com/jupyter/notebook/issues/2457


Solution

  • For support of arrow keys one needs bash instead of sh. However, bash is not supported by all docker images. I guess that's why docker does not have a configuration option to use bash as a default.

    If bash is installed for a specific container, you can symlink sh to bash inside the container, so that bash is used by default. Open a container console and type:

    ln -sf /bin/bash /bin/sh
    

    Close the console and open it again. Now you are using bash, supporting arrow key actions.

    It's possible to include that in the docker image as well.

    Also see:

    How to change the default /bin/sh to /bin/bash on opening CLI for selected container in Docker Desktop?

    https://phoenixnap.com/kb/symbolic-link-linux