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.

  • What docker image use for ionic CD / e2e testing? Ubuntu or just node?
  • Communication between linked docker containers
  • Docker-machine swarm; how to open ports on VM
  • Error while sharing local drive(volume) with docker for windows
  • How to serve static files with nginx inside of a docker container?
  • Linking multiple docker containers to one container with alias localhost using docker-compose
  • 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?

  • How To run from host machine bash script inside docker container and remain in bash in container [duplicate]
  • Backing up data volume containers off machine
  • how to run gunicorn on docker
  • How to view Docker image layers on Docker Hub?
  • Node.js - Error: [unixODBC] on db.open with Docker
  • Can docker containers within same host have same ports
  • 2 Solutions collect form web for “chown in docker not changing user to root”

    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"
    

    The newly released Docker for Mac has a different behavior regarding ownership:

    Initially, any containerized process that requests ownership metadata of an object is told that its uid and gid own the object. When any containerized process changes the ownership of a shared file system object, e.g. with chown, the new ownership information is persisted in the com.docker.owner extended attribute of the object. […]

    Michael’s start_safe_perms script can be adapted like the following to work consistently across platforms:

    if [[ -n $(mount -t fuse.osxfs) ]]; then
        chown -R www-data:www-data . 2> /dev/null
        # ...
    else
        read owner group owner_id group_id < <(stat -c '%U %G %u %g' .)
        adduser --system --uid=$(stat -c %u .) "$owner"
        # ...
    fi
    

    It basically detects if the mounted volume if of the type fuse.osxfs.

    You can checkout API Platform’s start_safe_perms script for a fully working example: https://github.com/api-platform/api-platform/blob/master/docker/apache/start_safe_perms

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.