I have used "bitnami/kubectl:latest" image to my test-c container which runs inside a test pod. I just login to that container and I wanted to create a file inside that container. But ended up with below error.
I have no name!@coredns-hook-c92g7:/$ touch test
touch: cannot touch 'test': Permission denied
I have no name!@coredns-hook-c92g7:/$ mkdir test
mkdir: cannot create directory 'test': Permission denied
Can someone help me to understand why this problem occurs and how to fix this? I am aware that mounting the file as configmap might help me but just I need to understand this issue. Thanks in advance!
CodePudding user response:
The issue here is that the docker image which you are using is configured to run its final instruction using a non-root user (USER 1001
in this case).
Have a look at the Dockerfile instruction: https://github.com/bitnami/bitnami-docker-kubectl/blob/master/1.24/debian-11/Dockerfile#L24
So you can either
- create files in a non-root user owned directory like
/tmp
or - create your own docker image after removing that
USER 1001
instruction from the Dockerfile and host it in your own repository which can then be pulled into your cluster.
Whatever works for you.
Hope this helps!