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
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:
xxxxxxxxxx
1
[root@localhost]# docker exec -ti auth-service /bin/bash
2
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 is quite simple.
xxxxxxxxxx
1
# Use /bin/sh instead of /bin/bash
2
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:
xxxxxxxxxx
1
$ docker exec -ti auth-service /bin/sh
Practical example from CMD:
xxxxxxxxxx
1
[root@localhost]# docker exec -ti auth-service /bin/sh
2
/ # ls -al
3
total 43548
4
drwxr-xr-x 1 root root 46 Oct 1 18:09 .
5
drwxr-xr-x 1 root root 46 Oct 1 18:09 ..
6
-rwxr-xr-x 1 root root 0 Oct 1 18:09 .dockerenv
7
drwxr-xr-x 2 root root 4096 May 9 2019 bin
So to sum up the post, we can login to docker container:
xxxxxxxxxx
1
# Using /bin/sh
2
docker exec -t -i PUT_CONTAINER_NAME_HERE /bin/sh
3
4
# Using /bin/bash
5
# Second option when our linux doesn't have /bin/sh, we need to use another shell /bin/bash
6
docker exec -t -i PUT_CONTAINER_NAME_HERE /bin/bash