11

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

2
  • is your /opt/ngcsc/start.sh executable? Commented Oct 12, 2016 at 23:39
  • yes, for sure. if I do not use entryPoint, I can execute it inside with no problem Commented Oct 13, 2016 at 0:08

2 Answers 2

4

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
Sign up to request clarification or add additional context in comments.

Comments

1

How about entering your command into a file and run that file with CMD? For example:

# start.sh
cd /opt/path ./start.sh -l dev -ssl false -srv api

# Dockerfile
# ... other commands
COPY start.sh /usr/local/bin/start/sh
CMD start.sh

start.sh should be in the same path as the Dockerfile and should be executable.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.