docker-compose volume wrong permission root

I’m trying to get wordpress working with docker but I have a lot a problem with the /wp-content/uploads folder, I use docker-compose and swarm.

this is part of the docker-compose:

  wordpress:
    depends_on:
      - db
    image: registry.gitlab.com/xxx/xxx
    volumes:
      - wordpress_data:/var/www/html/wp-content/uploads
    env_file:
      - wp.env
    networks:
      - sv-frontend
      - sv-backend

and this is my Dockerfile:

FROM wordpress:latest

COPY --chown=www-data:www-data . .

RUN mkdir -p /var/www/html/wp-content/uploads && 
    chown -R www-data:www-data /var/www/html/* && 
    ls -l  /var/www/html/wp-content/

the problem is that /wp-content/uploads has root:root as permission, what I’m doing wrong?

To deploy the app I use docker stack deploy..... the image is created using the gitlab pipeline but I don’t think is a gitlab problem

Source: StackOverflow