3 ms·
Regarding using USER somenonrootuser ... how do people deal with the need to write things out on container start? Some of my services require config file
by kelnos 6y ago
Regarding using
USER somenonrootuser
... how do people deal with the need to write things out on container start? Some of my services require config files, and I need to interpolate the values of environment variables into those config files, write them out, and then start the application. (Also assume the application itself doesn't have options for dropping privileges.) I'd rather not make the filesystem locations in question writable by `somenonrootuser`.
My current strategy is to let the container entrypoint start as root, but then I have a wrapper program installed that drops privileges before it exec()s the actual service. It works, but is there a better / more accepted way of doing this?
- Propaganda_ 6y agoIf the services can't be modified to load their config directly from env vars, write the config to an off-root scratch volume (e.g. mounted to /tmp/) and have them load from that. The root volume should be mounted read-only either way to prevent modification of your services should something get RCE.
- CGamesPlay 6y ago[deleted] this idea doesn't work on attempting
- piaste 6y agoIf you control the services, make them read from user-writable files instead of root ones. (Ideally you could skip the middleman and just read from env vars directly!) If you don't control the services, maybe in the Dockerfile you could write a dummy config file and chmod it?