Host OS: Debian 11 Bullseye
Docker version: 5:24.0.2-1~debian.11~bullseye
Container OS: Debian 10 Buster
Context
I am trying to containerize an app that I need to persist the state of across container restarts.
It is keeping all of its dynamic data in one directory in /var/lib/.
The simplest solution should therefore be overlaying that directory with a docker volume.
Under standard Docker operation, that isn't an issue, however, due to security concerns regarding potential container compromise and container escape exploits, we'd rather both the Docker daemon and the container app ran under non-root users.
Issue
As the app inside the container should also running as an unprivileged user, I was unable to mount the volume in such a way as for the app user to be able to write into it --
Setting the owner of the folder during the build phase is pointless as it only gets overlayed by the mount when the image is running.
And permissions cannot be changed after the container starts as it's already running in the context of the unprivileged user and the mountpoint is owned by root:root
Question
My question is simple -- Is there any way to achieve a RW volume mount inside the container for an unprivileged user?