Docker Compose on Windows - Volumes are owned by root

Hello. We’re using docker compose to set up a small container set for wordpress development. The compose file contains a volume to map wp-content to a directory on the host computer. The relevant part of docker-compose.yml is:

  wordpress:
    build: .
    depends_on:
      - db
    links:
      - db
    ports:
      - "8000:80"
    restart: always
    environment:
      WORDPRESS_DB_HOST: db:3306
      WORDPRESS_DB_PASSWORD: wordpress

    volumes:
      - ./uploads.ini:/usr/local/etc/php/conf.d/uploads.ini
      - ./zip.ini:/usr/local/etc/php/conf.d/zip.ini
      - ./wp-content:/var/www/html/wp-content

On mac this works fine but on windows the files in wp-content are all owned by root, with no way of changing the owner. (tried to docker exec a shell and run chown on the files but it didn’t work). This prevents among other things automatic installation of wordpress plugins (as the wp-content directory is not writable by the apache user)

Do anyone know how to change the owner of the files in the volume?

3 Likes