If I select any container and click CLI button, the /bin/sh
shell will be opened by default. Is there any way to manually reconfigure Docker to open /bin/bash
?
Asked
Active
Viewed 9,969 times
18

Hubert Jakubiak
- 853
- 8
- 19
-
1Not sure if there is an option but there is a command: `docker exec -it CONTAINER_NAME bash` – anemyte Aug 02 '21 at 07:02
-
container command prompt must be installed before we can use it. you get /bin/sh terminal prompt because most of the container have this shell environment by default. you can try any other container where bash is by default like Ubuntu or some other container? i doubt that we can change that from Docker itself. – Vinod Aug 02 '21 at 07:16
-
2@anemyte Yes, I know, but it's more convenient for me to click the CLI link from Docker Desktop app. – Hubert Jakubiak Aug 02 '21 at 15:11
-
2Docker Desktop should just make this an option in the settings. In Visual Studio, the "Open in Terminal" option in the Containers tab uses bash by default. – Jacob Stamm Sep 22 '22 at 15:06
3 Answers
8
It will depend on the base image, you can build a custom image and add bash if it is not available. And link the create a link to use bash instead of sh
FROM <BASE_IMAGE>
RUN apk add --no-cache bash
RUN ln -sf /bin/bash /bin/sh

Vijayaraghavan Sundararaman
- 814
- 1
- 7
- 12
6
Not exactly answer you asked for but for me it works to type bash
in sh terminal. It opens bash over the sh. Only nousance is that I must exit
twice.

Djoles
- 61
- 1
- 3
2
I changed default shell into bash
by making a new image with below Dockerfile
commands.
# Dockerfile
FROM <parent image>
# make /bin/sh symlink to bash instead of dash:
RUN echo "dash dash/sh boolean false" | debconf-set-selections
RUN DEBIAN_FRONTEND=noninteractive dpkg-reconfigure dash
# set ENV to execute startup scripts
ENV ENV ~/.profile
and create a new image.
$ docker build --tag <image> .
change symbolic link of
/bin/sh
tobash
https://superuser.com/questions/715722/how-to-do-dpkg-reconfigure-dash-as-bash-automatically
source ~/.profile
file when executing/bin/sh
If you want to clear
ENV
after startup, you may add below line to the~/.bashrc
file. (Be careful not to mess up other scripts)unset ENV

Seongbeom Park
- 21
- 1