Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OCI runtime exec failed: exec failed: container_linux.go:349: starting container process caused "exec:

I have created image with our application, after running the image i can see the docker containers are also created, when I am trying to getinto the docker container i am getting the below error, can you please help me here.

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

I have tried to execute all the below commands

 docker run -it exec 962f5d99458c
 docker run -it 962f5d99458c
 docker exec -it 962f5d99458c /bin
 docker exec -it 75f6cb44f9e1
 docker run --rm -ti 962f5d99458c sh
 docker run --rm -ti 962f5d99458c /bin
 docker exec  --rm -ti 962f5d99458c /bin
 docker exec  -ti 962f5d99458c /bin
 docker exec  -ti 962f5d99458c \bin
 docker exec -it 75f6cb44f9e1 bash

but no luck..... can you please help me here.

like image 518
Satya Mullangi Avatar asked Mar 10 '21 11:03

Satya Mullangi


1 Answers

What the error says is that the startup command is invalid because the image has no (or it's not on $PATH) certain executable in it (bash in this case). The absence of bash is adequate for certain images (e.g. based on Alpine Linux or scratch) but if there is any shell at all, you can use sh:

# create a container from image and get straight into shell
docker run -it <image> sh

# or start a container in background, then get into shell
docker run -d <image>
docker exec -it <container> sh

If the image has no shell in it, then the only way to launch it, is by using the binary of the application the image supposed to run. Normally it works out of the box, unless you've overridden ENTRYPOINT and/or CMD in Dockerfile or by run arguments. The default startup arguments can be found with docker inspect:

docker image inspect nginx | jq '.[0].Config.Entrypoint'
docker image inspect nginx | jq '.[0].Config.Cmd'

In case you absolutely sure that the executable is there but still get the error, using an absolute path might help (e.g. /bin/bash instead of simply bash).

like image 110
anemyte Avatar answered Sep 19 '22 14:09

anemyte