I want to mount a volume in the docker container as a non root user. I am using the following (k8s.yaml) -
volumeMounts:
- name: volume-to-be-mounted
mountPath: /location
volumes:
- name: volume-to-be-mounted
hostPath:
path: path
type: DirectoryOrCreate
This volume is mounted as root inside the container. But I want to mount it as non-root. Is there any way of doing this? I can also use the https://docs.docker.com/storage/volumes/ but I want to mount the same volume on other container (in the same pod) as well.
Some of the solutions that come to mind but don't suit my use case -
- change the permissions of the directory in entrypoint (not viable because entrypoint will be run as a non root user.)
- https://stackoverflow.com/a/39576814/9081810 I am using k8s.yaml to specify my requirements. I don't know how this solution will fit in.
Possible solutions that can work but I don't know how to do it -
- set permissions to 777 while mounting the volume.