I'm trying to access a shared certificate key from a rootless Podman container that is running OpenLDAP service as a non-root user. The key has group read rights and the user that is running my container is a member of this group. I wouldn't want to make a copy of the TLS key because then, if the key changes, the key would have to be copied again and this introduces extra complication and risk in the process.
Details:
I'm running the rootless Podman container with user ID 4610 and the user is a member of certs group (ID 1012) and group 4610. The user running the service inside container is not root either (the user ID inside the container is 4610 as well). I'm trying to mount the certificate key on the host which has a ownership root:certs and permissions rw-r----- to the container so that user 4610 inside the container would have access to it. Obviously on the host the user can access the file, because he is a member of certs group and the file has group read permission.
My /etc/subuid and /etc/subgid both have this line:
4610:100000:65536
If my docker-compose file has these lines, the container is allowed to access files whose owner is 4610 on the host:
userns_mode: "keep-id"
user: "4610"
This maps the host UID 4610 to the container so that if I have files whose owner is 4610 on the host, the owner inside the container is seen as 4610 as well. But the key file whose owner is root:certs on the host is seen owned by nobody:nogroup (IDs 65534:65534) inside the container.
How do I achieve the mount so that the user 4610 inside the container has access to the key file?