luksa/kubernetes-in-action

Chapter 6 permission error with sh script

siiiiiiiid opened this issue · 1 comments

Hi,

After building the fortune pod, when I deploy it to my GKE I get an error: crashloopbackoff which usually mean I have a container that stop immediately.

When I check the logs I have something like that:
kubectl logs fortune -c html-generator
/bin/sh: 1: /bin/fortuneloop.sh: Permission denied

So it seems my script does not have the exec permission so I added in the Dockerfile the permissions:
FROM ubuntu:latest

RUN apt-get update ; apt-get -y install fortune
ADD fortuneloop.sh /bin/fortuneloop.sh
RUN chmod +x /bin/fortuneloop.sh

ENTRYPOINT /bin/fortuneloop.sh

Now it works well.

Hope it help !
Seb

You can chmod the script outside of the Dockerfile and it will work, since Docker will copy the properties of the file.