Search code examples
macosdockercentos6.5

chown in docker not changing user to root


I am fairly new to Docker and have been setting up a Dockerfile and compose file to start up a server for testing.

When running a centos:6.6 image with a volume mapped to my user directory in OSX and installing httpd, my user for var/www/html is 1000:ftp instead of root:root.

I need to change a folder to user apache:apache in order to be able to upload files to it and cannot get chown or chmod to make any changes in any folder under var/www/html.
I know this has to do with me mapping my volume to a location on my OS drive.

So, my question is..

Is there anyway to set it up so that I can change ownership of var/www/html?


Solution

  • Issues 587 or 581 show that you can not change the ownership of a host mounted directory.

    Change instead your Apache start script in order to start it with the right id (1000) instead of apache:apache.
    See "apache/start_safe_perms" from Michael A. Smith

    Mainly:

    read owner group owner_id group_id < <(stat -c '%U %G %u %g' .)
    adduser --system --uid=$(stat -c %u .) "$owner"