docker: executable file not found in $PATH

后端 未结 10 989
刺人心
刺人心 2020-11-28 02:02

I have a docker image which installs grunt, but when I try to run it, I get an error:

Error response from daemon: Cannot start container foo_1         


        
相关标签:
10条回答
  • 2020-11-28 02:28

    This was the first result on google when I pasted my error message, and it's because my arguments were out of order.

    The container name has to be after all of the arguments.

    Bad:

    docker run <container_name> -v $(pwd):/src -it
    

    Good:

    docker run -v $(pwd):/src -it <container_name>
    
    0 讨论(0)
  • 2020-11-28 02:31

    There are several possible reasons for an error like this.

    In my case, it was due to the executable file (docker-entrypoint.sh from the Ghost blog Dockerfile) lacking the executable file mode after I'd downloaded it.

    Solution: chmod +x docker-entrypoint.sh

    0 讨论(0)
  • 2020-11-28 02:31

    A Docker container might be built without a shell (e.g. https://github.com/fluent/fluent-bit-docker-image/issues/19).

    In this case, you can copy-in a statically compiled shell and execute it, e.g.

    docker create --name temp-busybox busybox:1.31.0
    docker cp temp-busybox:/bin/busybox busybox
    docker cp busybox mycontainerid:/busybox
    docker exec -it mycontainerid /bin/busybox sh
    
    0 讨论(0)
  • 2020-11-28 02:33

    When you use the exec format for a command (e.g. CMD ["grunt"], a JSON array with double quotes) it will be executed without a shell. This means that most environment variables will not be present.

    If you specify your command as a regular string (e.g. CMD grunt) then the string after CMD will be executed with /bin/sh -c.

    More info on this is available in the CMD section of the Dockerfile reference.

    0 讨论(0)
  • 2020-11-28 02:38

    I found the same problem. I did the following:

    docker run -ti devops -v /tmp:/tmp /bin/bash
    

    When I change it to

    docker run -ti -v /tmp:/tmp devops /bin/bash
    

    it works fine.

    0 讨论(0)
  • 2020-11-28 02:39

    For some reason, I get that error unless I add the "bash" clarifier. Even adding "#!/bin/bash" to the top of my entrypoint file didn't help.

    ENTRYPOINT [ "bash", "entrypoint.sh" ]
    
    0 讨论(0)
提交回复
热议问题