11

I am currently trying to deal with a deployment to a kubernetes cluster. The deployment keeps failing with the response

 Error response from daemon: oci runtime error: container_linux.go:247: starting container process caused "exec: \"/entrypoint.sh\": permission denied"

I have tried to change the permissions on the file which seem to succeed as if I ls -l I get -rwxr-xr-x as the permissions for the file.

I have tried placing the chmod command both in the dockerfile itself and prior to the image being built and uploaded but neither seems to make any difference. Any ideas why I am still getting the error?

dockerfile below

FROM node:10.15.0
CMD []
ENV NODE_PATH /opt/node_modules

# Add kraken files
RUN mkdir -p /opt/kraken
ADD .  /opt/kraken/
# RUN chown -R node /opt/
WORKDIR /opt/kraken

RUN npm install && \
    npm run build && \
    npm prune --production

# Add the entrypoint
COPY ./entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
USER node
ENTRYPOINT ["/entrypoint.sh"]
tacoofdoomk
  • 121
  • 1
  • 1
  • 7

3 Answers3

11

This error is not about entrypoint error but command inside. Always start scripts with "sh script.sh" either entrypoint or cmd. In this case it would be: ENTRYPOINT ["sh", "entrypoint.sh"]

Akin Ozer
  • 1,001
  • 6
  • 14
  • 1
    `ENTRYPOINT ["sh", "entrypoint.sh"]` and `ENTRYPOINT ["/entrypoint.sh"]` are the same. So no need to do so. – Shudipta Sharma Aug 13 '19 at 17:18
  • 3
    Absolutely not same, one requires executable permission and one doesn't need. Just try and figure it out. – Akin Ozer Aug 13 '19 at 17:29
  • 1
    Then one has to insert `!#/bin/bash` or `!#/bin/sh` at the begining of the script. And how do you know that the script file has no this line – Shudipta Sharma Aug 13 '19 at 17:34
  • 1
    Well if you don't add that line you are in absolute disaster state. Your script's behaviour won't be same between environments and consistent, if you don't follow first rule of the bash script then it is your choice. – Akin Ozer Aug 13 '19 at 17:40
  • So, you can not tell that the script has no such line. And if thats true, prepending 'sh' in the ENTRYPOINT is not necessary and this is not the solution. – Shudipta Sharma Aug 13 '19 at 18:16
  • What type of arguments are you continuing? – Shudipta Sharma Aug 14 '19 at 02:12
-1

I created a github action with a Dockerfile and entrypoint.sh file. I run command 'chmod +x' in my computer and push to github repository. I did not RUN 'chmod +x' in Dockerfile. It works.

wjfqvi
  • 21
  • 2
-2

tray docker exec -it /bin/sh

Om Mo
  • 1
  • 1
  • 3
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jan 12 '22 at 12:12