Docker – exec: "bash": executable file not found in $PATH

If bash shell is not working, try sh.

Terminal

$ docker ps

CONTAINER ID        IMAGE               COMMAND               CREATED             STATUS              PORTS                  NAMES
3d1588519433        markdownhtml:0.1    "java -jar app.jar"   About an hour ago   Up About an hour    0.0.0.0:80->8080/tcp   gracious_haibt

$ docker exec -it 3d1588519433 bash

OCI runtime exec failed: exec failed: container_linux.go:349:
starting container process caused "exec: \"bash\": executable file not found in $PATH": unknown

The truth is, not every image is using the bash shell; try sh shell.

Terminal

$ docker exec -it 3d1588519433 sh

/home/hello #

References

mkyong

Founder of Mkyong.com, passionate Java and open-source technologies. If you enjoy my tutorials, consider making a donation to these charities.

15 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments
Aleksb86
4 years ago

Thanks sir! In Alpine Linux there is another yet shell – ash))

Md Asaduzzaman Atik
4 years ago
Reply to  Aleksb86

Thanks Man!!!!!!!!!

dewesh pushkar
2 years ago

Thanks a lot 🙂

Ridealist
3 years ago

Thanks… You save my life 🙂

ambiorixg12
3 years ago

It works perfect

docker exec -it 147bf86f4612 sh

Luis Bragado
3 years ago

Thanks a lot my friend!

naseem
3 years ago

thank you

Vinso
4 years ago

Thank you.

Thaamaraiselvan
4 years ago

Perfect….

Hajar Razip
4 years ago

Geeeeeeeeeeeeeeeeeeez thanks man. Exactly what I needed. I’m so used to running a ubuntu image I forgot this time I’m running an alpine. *face slap*

Sergey
5 years ago

Very useful tip, thank you!

Shubham
5 years ago

Thank You

Anurag
5 years ago

Thank you!

Mostefa
5 years ago

Thnx!

FX Bayu Anggara
5 years ago

Wow, thank you very much!