简体   繁体   中英

Docker container prints “no such file or directory”

I am fairly new to docker and I am completely stumped on how to fix my problem. I have searched and searched and nothing I've found has fixed my problem so far.

No matter what I do, I cant seem to get my bash script to be found and executed.

FYI - I'm using dockerfile-maven-plugin to kick-off the docker build process

Here is my dockerfile:

FROM openjdk:8-jre

WORKDIR /  ## I've also tried other directories, besides root

ARG JAR_FILE    ## variable inject via dockerfile-maven-plugin
ADD ${JAR_FILE} /motus-exec.jar

ADD run_motus.sh /
RUN ["chmod", "+x", "/run_motus.sh"]
ENTRYPOINT ["/run_motus.sh"]

Here is my script

#!/bin/sh
/usr/bin/java -jar /motus-exec.jar

Output from building docker image

[INFO] Step 1 : FROM openjdk:8-jre
[INFO] Trying to pull repository docker.io/library/openjdk ... 
[INFO] Pulling from docker.io/library/openjdk
[INFO] Digest: sha256:2216ccda45993afaa42b3b269aa1ae8832cb2fabbf8207f63d528fdc7c8a087b
[INFO] Status: Image is up to date for docker.io/openjdk:8-jre
[INFO]  ---> ed287c436e66
[INFO] Step 2 : WORKDIR /
[INFO]  ---> Running in 779de913ad3b
[INFO]  ---> 7ba637ea0ee8
[INFO] Removing intermediate container 779de913ad3b
[INFO] Step 3 : ARG JAR_FILE
[INFO]  ---> Running in 99c86f5273f0
[INFO]  ---> 8b0e9f39c1ab
[INFO] Removing intermediate container 99c86f5273f0
[INFO] Step 4 : ADD ${JAR_FILE} /motus-exec.jar
[INFO]  ---> 4bd2c163c7c3
[INFO] Removing intermediate container 9a9098d6e51a
[INFO] Step 5 : ADD run_motus.sh /
[INFO]  ---> 115cc9b09439
[INFO] Removing intermediate container 51e610f15427
[INFO] Step 6 : RUN chmod +x /run_motus.sh
[INFO]  ---> Running in 62dabd8b432e
[INFO]  ---> 8db646df2936
[INFO] Removing intermediate container 62dabd8b432e
[INFO] Step 7 : ENTRYPOINT /run_motus.sh
[INFO]  ---> Running in 330c5442d61a
[INFO]  ---> 0d9c0f6f5a34
[INFO] Removing intermediate container 330c5442d61a
[INFO] Successfully built 0d9c0f6f5a34

Output when I run image

>> docker run tl/motus-sol:0.2.2-SNAPSHOT
no such file or directory
docker: Error response from daemon: Container command not found or does not exist..

Thanks in advance for any assistance.

Docker run with 'Container command not found or does not exist' means the command in the entrypoint does not exist.

In your case the command in the .sh file: sh or java both exist in the image openjdk:8-jre. So you can check the issue in the shell script syntax. If you edit the sh file with a Windows editor, make sure you don't have the CRLF (\\r\\n) at the end of the command. One way to remove \\r is to run sed before add the sh file to the container:

sed -e 's/\r//g' run_motus.sh

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM