Docker
Mount a volume as the host user
This allows writing to the volume.
Dockerfile:
COPY .docker/entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh", "docker-php-entrypoint", "php-fpm"]
entrypoint.sh:
#!/usr/bin/env bash
echo "Checking USER ID"
www_uid=`stat -c "%u" /srv/app/src`
www_gid=`stat -c "%g" /srv/app/src`
echo "Host user is $www_uid:$www_gid"
if [ ! $www_uid -eq 0 ]; then
echo "Updating www-data user and group to match host IDs"
usermod -u $www_uid www-data
groupmod -g $www_gid www-data
fi
mkdir -p /srv/app/data
chown www-data:www-data /srv/app/data
exec "$@"
No Comments