wordpress-docker-compose icon indicating copy to clipboard operation
wordpress-docker-compose copied to clipboard

How to deal with the user permisions on the folders?

Open markdimi opened this issue 5 years ago • 8 comments

The folders that are created after running docker-compose up -d belong to the root user. How to deal with the user permissions?

I want to create a complete development environment thus I need complete access to wp-content for themes and plugins.

markdimi avatar May 15 '19 10:05 markdimi

I also had a similar issue on PHP containers for Laravel. I solved this using an entrypoint script: https://github.com/nezhar/laravel-docker-compose/tree/master/docker/php

I may add this also here in future.

nezhar avatar May 26 '19 20:05 nezhar

Hi, I'm testing your amazing job, but I still can't fix that user permissions folders. For instance with the WP Backoffice, I can't upload medias.

How did you by pass that issue ?

henrigoodvibes avatar Jul 01 '19 01:07 henrigoodvibes

Even though I don't like messing with permissions of folders, I changed them manually. Inside the root folder I give sudo chown -R $USER:$USER .

Don't forget the last dot.

markdimi avatar Jul 01 '19 09:07 markdimi

Even though I don't like messing with permissions of folders, I changed them manually. Inside the root folder I give sudo chown -R $USER:$USER .

Don't forget the last dot. Hello, That's exactly what I finished by doing. Thanks for your reply !

henrigoodvibes avatar Jul 03 '19 22:07 henrigoodvibes

Also you may try to run the container as an arbitrary user as provided in the docs of the PHP Docker image, as this is the base of the Wordpress image: https://hub.docker.com/_/php/

All you need for this is to extend the environmets of the wordpress service:

    environment:
      WORDPRESS_DB_HOST: db
      WORDPRESS_DB_NAME: "${DB_NAME}"
      WORDPRESS_DB_USER: root
      WORDPRESS_DB_PASSWORD: "${DB_ROOT_PASSWORD}"
      APACHE_RUN_USER: 1000
      APACHE_RUN_GROUP: 1000

nezhar avatar Sep 18 '19 19:09 nezhar

Also you may try to run the container as an arbitrary user as provided in the docs of the PHP Docker image, as this is the base of the Wordpress image: https://hub.docker.com/_/php/

All you need for this is to extend the environmets of the wordpress service:

    environment:
      WORDPRESS_DB_HOST: db
      WORDPRESS_DB_NAME: "${DB_NAME}"
      WORDPRESS_DB_USER: root
      WORDPRESS_DB_PASSWORD: "${DB_ROOT_PASSWORD}"
      APACHE_RUN_USER: 1000
      APACHE_RUN_GROUP: 1000

Hi, I've tried adding the "APACHE_RUN_USER: 1000" and "APACHE_RUN_GROUP: 1000" to fix the permission problem, but I get this: "apache2: bad user name 1000" Di you have any indication to solve this? Thanks in advance

d-castelli avatar Jan 14 '20 15:01 d-castelli

@d-castelli haven't tried it but have you tried adding the # before the id and group as specified in the doc nezhar referenced?

frandemona avatar Aug 12 '20 20:08 frandemona

Even though I don't like messing with permissions of folders, I changed them manually. Inside the root folder I give sudo chown -R $USER:$USER .

Don't forget the last dot.

This solution can fix the issue quickly, thanks a lot @markdimi

ArtNous avatar Dec 01 '20 13:12 ArtNous