'Permission denied' error over an internal container file

  • KM03793260
  • 31-Mar-2021
  • 09-Jun-2021

Summary

How to access and change the permissions over an internal container file.

Error

Inside an specific pod logs, you can encounter with a file 'Permission denied' over an internal file. Causing issues with a container function.

For example in side the pod 'itom-itsma-certificate-deployment' we found some issues when accessing the following container file:

# kubectl logs itom-itsma-certificate-deployment... -n itsma-toq1f -c certificate

time zone updated successfully.

/app/run.sh: line 18: /app/certificate-service/autopass/licenseserver/certs/db-root.crt: Permission denied

Cause

The user executing the action doesn't have enough permissions over the file.

Fix

A possible fix would be:

1. Connect to the affected container vis shell:

kubectl exec -it <pod> -n <namespace> -c <container> bash

For the previews example it woud be like:

kubectl exec -it itom-itsma-certificate-deployment... -n itsma-toq1f -c certificate bash

2. Change the file permissions:

            Like for example making it eadable, writable and executable by all users

 # chmod 777 /app/certificate-service/autopass/licenseserver/certs/db-root.crt