I met a really headache for this issue and almost pull my hair up and still can not resolve it. I want docker image to start automatically whenever I start it, so I came to using entrypoint, but always failed.
This is command I usually use to start my app:
cd /opt/path ./start.sh -l dev -ssl false -srv api
I now want to run this command automatically when docker get started.
I used this in docker file:
WORKDIR /opt/ngcsc
ENTRYPOINT ["start.sh","-l","kubstaging","-ssl", "false", "-srv", "api"]
I got this error:
docker: Error response from daemon: oci runtime error: exec: "start.sh": executable file not found in $PATH.
But if I change to absolute path:
ENTRYPOINT ["/opt/ngcsc/start.sh","-l","kubstaging","-ssl", "false", "-srv", "api"]
after I run docker run image
I got:
standard_init_linux.go:175: exec user process caused "exec format error"
This is really a big problem and I googled a lot, nothing worked. can you help to tell me what to do?
Thanks
Unix is looking for an executable binary to exec, not a shell script. To run the shell script, call it with the appropriate shell, e.g.:
ENTRYPOINT ["/bin/sh", "-c", "/opt/ngcsc/start.sh","-l","kubstaging","-ssl", "false", "-srv", "api"]
Note that this won't make docker automatically start your container when the host reboots. For that, you want the --restart
flag on docker run
, e.g.:
docker run --restart=unless-stopped -itd your_image
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With