Docker entrypoint permission denied
Asked Answered
A

3

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"]
Aureus answered 13/8, 2019 at 16:34 Comment(5)
Post your DockerfileStraw
Here, some tasks of a certain sequence are needed to be done. Give proper permission to /entrypoint.sh file in the dockerfile, build it, push it, if the imagePullPolicy is set"IfNotPresent" then update the image with the new one, and deployDoralynn
Can you provide your podTemplate?Doralynn
Op, clear the requirments, those are needed to explain what you have done better.Doralynn
@Aureus Are you using minikube or other cluster?Doralynn
D
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"]

Divestiture answered 13/8, 2019 at 17:1 Comment(6)
ENTRYPOINT ["sh", "entrypoint.sh"] and ENTRYPOINT ["/entrypoint.sh"] are the same. So no need to do so.Doralynn
Absolutely not same, one requires executable permission and one doesn't need. Just try and figure it out.Divestiture
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 lineDoralynn
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.Divestiture
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.Doralynn
What type of arguments are you continuing?Doralynn
M
-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.

Mare answered 30/11, 2021 at 11:49 Comment(0)
T
-2

tray docker exec -it /bin/sh

Tricycle answered 12/1, 2022 at 11:36 Comment(1)
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.Grendel

© 2022 - 2024 — McMap. All rights reserved.