4

I want to use a bash script as the entrypoint in the dockerfile. The code as blow:

ENV INST  INIT
ADD start.sh /start.sh
RUN chmod 777 /start.sh
ENTRYPOINT /start.sh $INST

It should be right. But when I build the image and run it, the result as below:

/bin/sh: 1: /start.sh: not found

Could anyone help me? Thanks. Total Dockerfile:

FROM debian:latest

ENV INST  INIT
RUN apt-get update
RUN apt-get install -y git build-essential gcc g++ vim 


RUN mkdir /Lab-C-Framework
WORKDIR /Lab-C-Framework
ADD Lab-C-Framework /Lab-C-Framework
RUN make install
RUN chmod 777 -R /Lab-C-Framework

RUN mkdir /project
ADD bin /project
ADD src /project
ADD header /project
ADD tests /project
ADD Docs /project
ADD Makefile /project
RUN chmod 777 -R /project

ADD start.sh /start.sh
RUN chmod 777 /start.sh

RUN mkdir /code
RUN chmod 777 /code
VOLUME /code 
WORKDIR /code


ENTRYPOINT /start.sh $INST
1
  • 1
    I would add the script to the /bin directory on the container and use start.sh without the / as the entry point. Commented May 12, 2017 at 8:32

2 Answers 2

4

It looks like the first line in your /start.sh script is pointing to something that doesn't exist. If it's a #!/bin/bash you would need to have bash installed in the image. And if your shell is installed in the container, make sure your first line doesn't have a windows linefeed at the end.

Sign up to request clarification or add additional context in comments.

2 Comments

ty for this one, saved me some time!
wrong line endings were the problem. Wow! I couldn't have figured it out myself. This is the case when misleading error message is worse than a cryptic one.
3

you could try to set your entry point using:

COPY start.sh /start.sh
RUN chmod +x /start.sh
ENTRYPOINT ["/start.sh", "$INST"]

If you can edit the start.sh script you couls probably read the $INST variable right from the environment without the need of passing it as a parameter.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.