luksa / kubernetes-in-action

Code from the Kubernetes in Action book
1.92k stars 1.39k forks source link

Chapter 6 permission error with sh script #22

Open siiiiiiiid opened 4 years ago

siiiiiiiid commented 4 years ago

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

ilknarf commented 4 years ago

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