-
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
Upgrade of plugins doesn't work if they are on a mounted volume #352
Comments
I seem to have the same or a related issue... I've been using a dockerfile like this (slightly shortened and anonymized): FROM wordpress:4.9.8-php7.2-apache
RUN apt-get update && apt-get install -y wget unzip
# copy custom plugin
COPY plugins/somecustomplugin /usr/src/wordpress/wp-content/plugins/somecustomplugin
# copy configs
COPY wp-config-sample.php /usr/src/wordpress/wp-config-sample.php
COPY ./htaccess /usr/src/wordpress/.htaccess
COPY supercache/advanced-cache.php /usr/src/wordpress/wp-content/advanced-cache.php
COPY supercache/wp-cache-config.php /usr/src/wordpress/wp-content/wp-cache-config.php
# copy theme
COPY mythemename /usr/src/wordpress/wp-content/themes/mythemename
# install plugins
RUN wget https://downloads.wordpress.org/plugin/simple-image-sizes.3.2.0.zip -O /tmp/simple-image-sizes.zip \
&& unzip /tmp/simple-image-sizes.zip -d /usr/src/wordpress/wp-content/plugins/
RUN wget https://downloads.wordpress.org/plugin/wp-super-cache.1.6.4.zip -O /tmp/wp-super-cache.zip \
&& unzip /tmp/wp-super-cache.zip -d /usr/src/wordpress/wp-content/plugins/
# etc. etc... Today I've updated a few plugin without changing the tag number for wordpress itself, and now it doesn't update and wp-supercache is complaining:
etc. Has someone changed the image without changing the tag somehow? I thought the point of tags were that they should be immutable, but it seems even a fairly specific tag such as I tried manually chmod'ing some specific plugins to enable them to update, such as: |
Actually I just tried adding RUN chmod 766 -R /usr/src/wordpress/wp-content at the bottom of my dockerfile, and this made things worse, all I now get at /wp-admin/ is:
Btw, I'm not even sure if our setup really has the plugin dirs etc in a "mounted volume" the only mention of volumeMounts:
- name: mysite-storage
mountPath: /var/www/html/wp-content/uploads/ and it's supposed to only map the uploads dir to a persistent volume. |
Ah... Found this article: https://renovatebot.com/blog/docker-mutable-tags Weirdly, it seems that docker tags are not meant to be immutable. (They really should have called them "branches" then, and displayed a list of digests next to each branch on dockerhub if you ask me). Anyway... FROM wordpress:4.9.8-php7.2-apache@sha256:54ccbf55f2f303caae2aa8ebb644796b9240a0541831c0ac51bf372de008da24 There are probably newer versions that work, but this is the digest that happened to be used last time I built my site ca. 2 months ago. Using this I can now update translations and plugins again, and supercache is not complaining anymore. |
For the original issue did you set the correct permissions for those directories on the host, I'm not able to reproduce an issue when setting appropriate permissions/ownership
For @strindhaug's issue I'm not able to reproduce any problem either, I set appropriate permissions on the host directories and when they're copied into the container at wordpress/php7.2/apache/docker-entrypoint.sh Lines 53 to 83 in a748aaf
Updating akismet with it being owned by root, undergone a $ ls -l | grep plugins
drwxrwxrwx 4 root root 4096 Dec 4 13:42 plugins/
$ ls -l plugins
total 16
drwxrwxrwx 4 root root 4096 Dec 4 13:42 akismet/
drwxrwxrwx 7 root root 4096 Dec 4 13:42 gutenberg/
-rwxrwxrwx 1 root root 2230 Dec 4 13:42 hello.php*
-rwxrwxrwx 1 root root 28 Dec 4 13:42 index.php* The DockerfileFROM wordpress:4.9.8-php7.2-apache
RUN apt-get update && apt-get install -y wget unzip
# copy custom plugin
COPY plugins /usr/src/wordpress/wp-content/plugins
# copy configs
COPY wp-config-sample.php /usr/src/wordpress/wp-config-sample.php
COPY ./htaccess /usr/src/wordpress/.htaccess
# copy theme
COPY mythemename /usr/src/wordpress/wp-content/themes/mythemename
# install plugins
RUN wget https://downloads.wordpress.org/plugin/simple-image-sizes.3.2.0.zip -O /tmp/simple-image-sizes.zip \
&& unzip /tmp/simple-image-sizes.zip -d /usr/src/wordpress/wp-content/plugins/
RUN wget https://downloads.wordpress.org/plugin/wp-super-cache.1.6.4.zip -O /tmp/wp-super-cache.zip \
&& unzip /tmp/wp-super-cache.zip -d /usr/src/wordpress/wp-content/plugins/ |
I'm not explicitly installing akismet, it's included in the standard wordpress install; so it's mode flags should be exactly as intended. I'm not even using it, but it's an example of a plugin that definitely should work straight out of the box since it's not something I'm modifying in any way from the wordpress image. The build 2 moths ago was on 15. october so presumably the changes that made it stop working is somewhere in this diff here: The only obvious changes I notice besides some structural refactoring, is the removal of the argument # strip off any '#' symbol ('#1000' is valid syntax for Apache)
pound='#'
user="${user#$pound}"
group="${group#$pound}" to some code I do not understand at all. All i know is that the digest as of 15. october: FROM wordpress:4.9.8-php7.2-apache@sha256:54ccbf55f2f303caae2aa8ebb644796b9240a0541831c0ac51bf372de008da24 works just fine, and the current digest: FROM wordpress:4.9.8-php7.2-apache@sha256:7e476394586459bb622d3f37448cd07e703ec6906257d232542f2f51ff073da7 does not. BTW, plugins installed explicitly in my Dockerfile like so:
has never been possible to update automatically, so presumably unzip doesn't set suitable mode flags; but I don't think subfolders of wp-content with weird mode flags should cause the wp-content folder itself to be write protected? My Dockerfile is built using circle-ci, running within a alpine-based image, and deployed to a kubernetes cluster on aws, if that has any effect on it. (I should think it would not, since the whole point of docker images as far as I can tell is that they are self-contained images that should behave identically no matter where they're run. But I also naively thought that tags with a specific name should stay the same as well, so I guess I cannot trust my intuition with anything Docker related... ;) ) |
Maybe it's the Presumably this prevents tar from updating flags on existing directories as well as overwriting them. |
Oh, I think I've got it... While #351 is preventing tar from creating access denied errors when modifying existing files, it also prevents tar from setting the correct owner on /var/www/html/wp-content/ itself. If the current behavior is more useful, there should probably be added a few separate This explains why my attempts at explicitly setting flags to /usr/src/wordpress/wp-content/ or subfolders and files had no effect on the newest version, since the |
I guess both docker-compose and kubernetes when mounting volumes ensures the parent directories of the mountpath exists running |
@controlcde your deployment would probably be simpler if you just mounted the full I'm a little bit confused at the use case here (mounting just plugins and still expecting them to be able to update), but from what I can tell all the issues listed above are related to permissions, specifically on directories? If the issue is that If you want to run a production WordPress instance within Docker, I would highly recommend mounting the entire WordPress directory as upstream recommends and letting WordPress auto-update DTRT automatically. If you want new installs to have certain plugins pre-installed, put them under The ability to mount/use plugins directly in Regardless of all this, setting appropriate permissions in an odd setup like that are the purview of the user and not something the image will automatically resolve for you. For further help debugging your deployment or developing your |
In case someone else finds this issue and have the same problem as I had: It works fine if you just move the mount-point for your uploads folder to just outside the wp-content content directory something like this: Change the mountPath in k8s/statefulset.yml like this:apiVersion: apps/v1beta1
kind: StatefulSet
metadata:
name: myappname
spec:
replicas: 1
serviceName: myappname
template:
metadata:
labels:
app: myappname
spec:
containers:
- name: myappname
# [...]
volumeMounts:
- name: myappname-storage
# old value:
# mountPath: /var/www/html/wp-content/uploads/
# new value:
mountPath: /var/www/html/uploads/
volumeClaimTemplates:
- metadata:
name: myappname-storage
# [...] Add this line to wp-config-sample.php:define('UPLOADS', 'uploads'); // use custom uploads mount point (default is "wp-content/uploads") (Note that unless you have some other url remapping configured, the image url will contain the text from the Don't use the pinned old version of wordpress I suggested above as a hack (though it's good to know about the option of using the digest to specify a version as a workaround if some other bug appears in an update on a previously working tag) |
I´m using docker compose to create all my wordpress container. If I create my container with mount volumes for plugins, themes and languages I can´t update/upgrade all of this. Here are my configurations:
Normally all setting should be fixed with creation, but I think it doesn't work well.
If I temporary disable the volumes the wp-content directory has the right permissions.
The text was updated successfully, but these errors were encountered: