docker-apache-php53 icon indicating copy to clipboard operation
docker-apache-php53 copied to clipboard

How to change user:group for the linked www directory?

Open mpathy opened this issue 8 years ago • 1 comments

The docker image works, but the User and Group comes from the directory which links into the docker image. The user and group is wrong there, its 5006 and 5005 instead of www-data like in the original directory.

What can I do to either have the same user and group or to tell Apache that it should not mind wrong user and group?

mpathy avatar Nov 27 '17 13:11 mpathy

This lies in the nature of Docker: The internal (container) users do not match with the external (host) users: So the Apache in my docker container is running under the www-data account, which has UID 33 within the container. If you mount the /var/www dir from a host, it has the host's file UIDs assigned.

One solution would be to use Docker Volumes: The linked stackoverflow article describes this in detail:

https://stackoverflow.com/questions/23544282/what-is-the-best-way-to-manage-permissions-for-docker-shared-volumes

Please also have a look at the Docker volume manual:

https://docs.docker.com/engine/reference/commandline/volume_create/

Perhaps this helps. If you just want to give the web server (www-data) write access to a specific dir, then the easiest way is to chown / chmod from within the container: docker exec -ti [containername] chown -R www-data:www-data /var/www/path/to/your/dir

Maybe this helps.

bylexus avatar Nov 27 '17 21:11 bylexus