Languages
[Edit]
EN

Fix for docker error - OCI runtime exec failed: exec failed: container_linux.go:349: starting container process caused "exec: \"/bin/bash\": stat /bin/bash: no such file or directory": unknown

10 points
Created by:
Jun-L
873

Hi, today I would like to share with you solution to a problem I've encountered when I tried to login to docker container.

My error:

[root@localhost]# docker exec -ti auth-service /bin/bash
OCI runtime exec failed: exec failed: container_linux.go:349: starting container process caused "exec: \"/bin/bash\": stat /bin/bash: no such file or directory": unknown

Solution

Solution is quite simple.

# Use /bin/sh instead of /bin/bash
docker exec -t -i PUT_CONTAINER_NAME_HERE /bin/sh

Explanation:

The docker container didn't have /bin/bash installed, so I used /bin/sh instead and it solved my problem. 

Example of correct login to docker container using /bin/sh:

$ docker exec -ti auth-service /bin/sh

Practical example from CMD:

[root@localhost]# docker exec -ti auth-service /bin/sh
/ # ls -al
total 43548
drwxr-xr-x    1 root     root            46 Oct  1 18:09 .
drwxr-xr-x    1 root     root            46 Oct  1 18:09 ..
-rwxr-xr-x    1 root     root             0 Oct  1 18:09 .dockerenv
drwxr-xr-x    2 root     root          4096 May  9  2019 bin

 

Summary

So to sum up the post, we can login to docker container:

# Using /bin/sh
docker exec -t -i PUT_CONTAINER_NAME_HERE /bin/sh

# Using /bin/bash
# Second option when our linux doesn't have /bin/sh, we need to use another shell /bin/bash
docker exec -t -i PUT_CONTAINER_NAME_HERE /bin/bash

 

References:

Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join