How to manage permissions for a volume mounted into a docker container?

Solution:

You can do this by overwriting the entrypoint for the wordpress image.

Create a file startup.sh in your project and make is executable:

#!/bin/bash

chown -R www-data:www-data /var/www/html/wp-content
docker-entrypoint.sh apache2-foreground

Then in your docker-compose.yml:

...
  wordpress:
...
    working_dir: /var/www/html
    volumes:
        - './my-theme:/var/www/html/wp-content/themes/my-theme'
        - './startup.sh:/startup.sh'
    entrypoint: /startup.sh

This worked for me, let me know if you have problems implementing it.