My set-up
- I have a Docker image based on
php:7.4-apache
. - I have two Docker volumes for saving files that need to be persisted.
- On container start, I run Certbot to install HTTPs certificates.
Issue
I discovered that my application can't write to Docker volumes.
Debugging
Using ls -l
I found out that the mountpoints of my volumes are owned by user 1451
:
drwxr-xr-x 4 1451 users 176128 Mar 12 13:25 volume_mountpoint
My web server is running under user www-data
.
Attempted solution
I've tried setting the user under which my container runs to www-data
. This caused the volume mountpoints to be owned by www-data
, which fixed the permissions issue. The problem with this solution is that Certbot
requires root
permissions and fails to acquire HTTPs certificate without it.
Question
What is the proper way to fix this issue? I need Certbot
to run under root, but let mountpoints to be owned by www-data
.