Docker Community Forums

Share and learn in the Docker community.

Docker exec -it /bin/bash don't work

(Ddoocker) #1

I need some help please. I am new to docker. I installed docker for windows on a windows 10 machine so that i can use both linux an windows containers. The installation and the configuration went well but when i tried to create my first container, i faced a problem: i tried to execute an interactive bash shell on the container but that didn’t work. i have no output and no errors in log file. Here’s the commands that i tried

docker exec -it “container-id” bash

docker exec -it “container-id” /bin/bash
But when i run exec without a tty or input, that’s working. e.g

docker exec “container-id” ls .
Can someone help me?

(Brett Cooper) #2

Is bash present in the container?
In Kitematic you can add to the parameters SHELL /bin/bash
to automatically start bash when you opened the containers cli

(Ddoocker) #3

i think that container doesn’t have bash installed. Do you know how to fix that ?

(Brett Cooper) #4

not really. running apt-get update and then apt-get install bash works but doesn’t add it to the image only the container and is reset when the container is reset.

You have to do something like save it as a new image.

(Tusharniras) #5

Hi @ddoocker,
Which image are you using?

(Giddo4all) #6

What error are you getting?
On windows, try the same command in windows cmd (not switching to bash).

(Drumsticks) #7

This worked for me. Thank you for the recommendation. I now wonder why this command does not work in Bash. I love Bash and prefer to use one type of CLI instead of several, since I use Git Bash for all things Git. Would you happen to know the reason why this command does not work in Bash? Is there a work-around or fix to make this command work in Bash? Thank you, again, for your time!