-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
wp-content is owned by root on creation #436
Comments
If you mount the parent directory as well it should have appropriate permissions
|
So is that a workaround? It seems like a common need and something that could be checked for in entrypoint.sh |
The parent |
makes sense. i just assumed there could be a one line script to just check for that folder afterwards and chown accordingly... but I'm admittedly somewhat green here. |
I support it.. I do it a bit differently - I copy in advance wp-content folder and my chown commands gets totally ignored: Here is my dockerfile:
I still get everything as root:root |
I changed my |
Does anyone have a working example of a docker-compose.yml that actually allows mounting a shared theme/plugin without causing permission issues in the docker container? I've been running in circles for a long time now trying to switch to Docker for automated e2e testing and I just can't get past these permissions issues. I now have it so it's mounting directories as 1000:1000 (the uid/gid of my host user) but the filesystem still doesn't work right as a result. Edit: word |
The place to start experimenting/debugging wordpress/docker-entrypoint.sh Lines 30 to 31 in 0df5de0
|
EDIT: For some reason, the above doesn't work, as it fails to copy the contents from |
Makes the WordPress content directories (wp-content, wp-content/plugins, wp-content/themes) owned by the www-data user. This ensures that WordPress can write to these directories. This is necessary when running wp-env with `"core": null` because Docker will automatically create these directories as the root user when binding volumes during `docker-compose up`, and `docker-compose up` doesn't support the `-u` option. See docker-library/wordpress#436.
Makes the WordPress content directories (wp-content, wp-content/plugins, wp-content/themes) owned by the www-data user. This ensures that WordPress can write to these directories. This is necessary when running wp-env with `"core": null` because Docker will automatically create these directories as the root user when binding volumes during `docker-compose up`, and `docker-compose up` doesn't support the `-u` option. See docker-library/wordpress#436.
I made some changes to fix this issue in #474 |
Makes the WordPress content directories (wp-content, wp-content/plugins, wp-content/themes) owned by the www-data user. This ensures that WordPress can write to these directories. This is necessary when running wp-env with `"core": null` because Docker will automatically create these directories as the root user when binding volumes during `docker-compose up`, and `docker-compose up` doesn't support the `-u` option. See docker-library/wordpress#436.
Makes the WordPress content directories (wp-content, wp-content/plugins, wp-content/themes) owned by the www-data user. This ensures that WordPress can write to these directories. This is necessary when running wp-env with `"core": null` because Docker will automatically create these directories as the root user when binding volumes during `docker-compose up`, and `docker-compose up` doesn't support the `-u` option. See docker-library/wordpress#436.
Any solution to it? |
this is still a problem for me |
it works if i add to my docker-compose.yml |
It would help to have a minimal example to reproduce the issue if you want us to look into it. 😉 |
@tianon this is the docker-compose.yml that worked for me: version: '3.1'
services:
homeconvey:
image: wordpress
restart: always
environment:
WORDPRESS_DB_HOST: $WORDPRESS_DB_HOST
WORDPRESS_DB_USER: $WORDPRESS_DB_USER
WORDPRESS_DB_PASSWORD: $WORDPRESS_DB_PASSWORD
WORDPRESS_DB_NAME: $WORDPRESS_DB_NAME
WORDPRESS_TABLE_PREFIX: $WORDPRESS_TABLE_PREFIX
# WORDPRESS_AUTH_KEY:
# WORDPRESS_SECURE_AUTH_KEY:
# WORDPRESS_LOGGED_IN_KEY:
# WORDPRESS_NONCE_KEY:
# WORDPRESS_AUTH_SALT:
# WORDPRESS_SECURE_AUTH_SALT:
# WORDPRESS_LOGGED_IN_SALT:
# WORDPRESS_NONCE_SALT:
# WORDPRESS_DEBUG:
# WORDPRESS_CONFIG_EXTRA:
ports:
- '8080:80'
volumes:
- $VOLUME_PATH:/var/www/html
- /path/to/my/theme/:/var/www/html/wp-content/themes/homeconveytheme/:ro
- /path/to/my/plugin/:/var/www/html/wp-content/plugins/homeconveyplugin/:ro
command: /bin/sh -c "chown www-data:www-data wp-content wp-content/plugins wp-content/themes && exec apache2-foreground"
networks:
- mariadb-docker_backend
networks:
mariadb-docker_backend:
external: true i am using docker to be able to see my plugin and theme read only during development. without the chown command it seems everything gets owned by root so the installation cannot install any plugins or updates or anything. seems to happen when linking the bottom 2 volumes |
Are you using a new enough image? #503 was added for this exact use case (and built with docker-library/official-images#8200). You'll likely need to have an empty
So, if you use a host path in a wordpress:
image: wordpress
volumes:
- './theme:/var/www/html/wp-content/themes/homeconveytheme/:ro'
- './plugin:/var/www/html/wp-content/plugins/homeconveyplugin/:ro' Not pre-creating the directories: $ docker pull wordpress
Using default tag: latest
latest: Pulling from library/wordpress
...
Digest: sha256:93ee786387237f25705610977d5f506c87ea99b1f207aa2441a027b2b5f8a7a2
Status: Downloaded newer image for wordpress:latest
docker.io/library/wordpress:latest
$ docker-compose -f docker-compose.yml run wordpress bash
root@281136d991cb:/var/www/html# ls -la
total 12
drwxrwxrwx 3 www-data www-data 4096 Sep 2 17:00 .
drwxr-xr-x 1 root root 4096 Aug 5 04:17 ..
drwxrwxrwx 4 www-data www-data 4096 Sep 2 17:00 wp-content
root@281136d991cb:/var/www/html# ls -la wp-content/
total 16
drwxrwxrwx 4 www-data www-data 4096 Sep 2 17:00 .
drwxrwxrwx 3 www-data www-data 4096 Sep 2 17:00 ..
drwxrwxrwx 3 www-data www-data 4096 Sep 2 17:00 plugins
drwxrwxrwx 3 www-data www-data 4096 Sep 2 17:00 themes
root@281136d991cb:/var/www/html# ls -la wp-content/*
wp-content/plugins:
total 12
drwxrwxrwx 3 www-data www-data 4096 Sep 2 17:00 .
drwxrwxrwx 4 www-data www-data 4096 Sep 2 17:00 ..
drwxr-sr-x 2 root root 4096 Sep 2 16:59 homeconveyplugin
wp-content/themes:
total 12
drwxrwxrwx 3 www-data www-data 4096 Sep 2 17:00 .
drwxrwxrwx 4 www-data www-data 4096 Sep 2 17:00 ..
drwxr-sr-x 2 root root 4096 Sep 2 16:59 homeconveytheme Pre-creating the directories: $ sudo rmdir plugin/ theme/
$ mkdir plugin/ theme/
$ ls -ln
total 12
-rw-rw-r-- 1 1000 1000 960 Sep 2 09:59 docker-compose.yml
drwxr-sr-x 2 1000 1000 4096 Sep 2 10:06 plugin
drwxr-sr-x 2 1000 1000 4096 Sep 2 10:06 theme
$ docker-compose -f docker-compose.yml run wordpress bash
root@b1f7239f8720:/var/www/html# ls -la wp-content/*
wp-content/plugins:
total 12
drwxrwxrwx 3 www-data www-data 4096 Sep 2 17:07 .
drwxrwxrwx 4 www-data www-data 4096 Sep 2 17:07 ..
drwxr-sr-x 2 1000 1000 4096 Sep 2 17:06 homeconveyplugin
wp-content/themes:
total 12
drwxrwxrwx 3 www-data www-data 4096 Sep 2 17:07 .
drwxrwxrwx 4 www-data www-data 4096 Sep 2 17:07 ..
drwxr-sr-x 2 1000 1000 4096 Sep 2 17:06 homeconveytheme
root@b1f7239f8720:/var/www/html# |
@yosifkit was your $VOLUME_PATH folder completely empty before running docker-compose build? the wp-content directory and sub folders get created as root on my end. i am pretty sure i am using the latest because i only just started using it in august |
I was using an anonymous docker volume and not a host path for volumes:
- type: bind
source: $VOLUME_PATH
target: /var/www/html
volume:
nocopy: true EDIT: this doesn't work 😢 (#436 (comment)) |
@yosifkit in order to use long form i had to change to version 3.3 at the top of the docker compose file. i cleared the directory and ran it. there is no change as the wp-content directory is still owned by root. i am not even sure if the volume->nocopy applies to a type of bind as it isn't a volume? i might consider switching to a volume as i don't really need to bind to filesystem. or otherwise i can just stick with my solution. thanks |
i can confirm that if i use a volume it works fine |
Yeah, apparently Docker thought it wouldn't be useful to allow So if you need to mount both the base wordpress dir, and custom themes/plugins directories, then the empty directories need to be created within the wordpress directory with the correct permissions. Alternatively, you could just use one mount and put the custom themes directly in your wordpress folder (assuming you didn't need the
Or just use a named docker volume. |
I originally published this solution in Stackoverflow, but because they're referring to a similar issue I'll publish it also here in case it helps someone. ProblemThe parent SolutionCustom entrypoint executing a delayed command that sets the ownership after Your Dockerfile FROM wordpress:php7.4-apache
[...]
ENTRYPOINT ["/entrypoint.sh"] Your entrypoint.sh # In 10 seconds set the ownership
$(sleep 10 && chown -R www-data:www-data /var/www/html/) &
# Run the parent's ENTRYPOINT and CMD as defined in its Dockerfile
# (https://github.com/gsusI/wordpress/blob/master/php7.4/apache/Dockerfile)
docker-entrypoint.sh apache2-foreground # run parent entrypoint.
|
It seems we should be able to mount
themes
andplugins
anduploads
separately, but for some reason it appears that when I remove and re-create wordpress using docker-compose, wp-content is always owned by root.The text was updated successfully, but these errors were encountered: