0

When I exec the commmand, it occur this error

docker run -it --entrypoint=/bin/bash ld_mmdet:2.4.0 /bin/bash
docker: Error response from daemon: oci runtime error: container_linux.go:247: starting container process caused "exec: \"/bin/bash\": stat /bin/bash: no such file or directory".

then I inspect the images, and found the cmd is null, like this

 "ContainerConfig": {
            "Hostname": "",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": null,
            "Cmd": null,
            "Image": "",
            "Volumes": null,
            "WorkingDir": "",
            "Entrypoint": null,
            "OnBuild": null,
            "Labels": null
        },

So, is there any solution to resolve this? I have try the methods as follows:

  • using /bin/sh or /bash instead of /bin bash,NOT WORK
  • using docker run -it --entrypoint=/bin/bash ld_mmdet:2.4.0 /bin/bash,NOT WORK
2
  • 1
    Do you have a reason for using --entrypoint? What image are you using? Aug 19, 2020 at 9:30
  • 1
    Does the image ld_mmdet:2.4.0 have /bin/bash inside? Cannot help without knowing how this image is built.
    – Shashank V
    Aug 19, 2020 at 9:39

1 Answer 1

2

First, a good practice is launching docker in detached mode and then access it with docker exec -it, for example.

Second, you need to specify an entrypoint or command that doesn't finish.

All /bin/bash, /bin/sh command finishes unless you add args such as sleep infinity or similar. I recommend you execute tail -F /dev/null and then access docker with your bash or sh.

docker run -d --name mymmdet ld_mmdet:2.4.0 tail -F /dev/null
docker exec -ti mymmdet bash

You can verify after docker run command if your docker is running with docker ps -a, and if it's up, then docker exec.

11
  • 1
    Running bash in interactive mode in a terminal (-it) does not finish. The problem here (beside the fact that using the same binary as entrypoint and command is odd...) is that bash is not installed inside the image or at least not in the path that OP is using. Solving the issue requires to know what is the base image he is using (wich is why I voted to close for lack of debugging info). Aug 19, 2020 at 9:44
  • 1
    (I don't think there's anything wrong with docker run --rm -it imagename sh to get a temporary container with a debugging shell.)
    – David Maze
    Aug 19, 2020 at 9:45
  • @Zeitounator, I'm not saying that -it finishes. bash as command or entrypoint does if you launch it detached. Aug 19, 2020 at 9:56
  • You don't need to detach in that case if you only want to run bash. And the problem will remain if you detach a never ending command and try to exec a non existing bash on the container later (If it eventually started correctly...). In this case, it only introduces complexity IMO and does not fix OP's problem at all. Aug 19, 2020 at 10:03
  • 2
    I don't agree it is a good practice in all cases. If you only need to run bash or a single command it might even be a bad one. Aug 19, 2020 at 10:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.