I\'m running a php-fpm wordpress container.
The wordpress source files are mounted in a named volume "wordpress" shared with the Nginx container.
Everyth
When the wordpress container comes up it checks for the existence of files at /var/www/html
and copies only if not present. So in your case may you can update the entrypoint
script to check the wordpress version in the wp-includes/version.php
in the /var/www/html
and the files in the container and then make a decision to replace the new files.
Edit:
According to this just deletion of index.php
or wp-includes/version.php
should copy the files from container again. Or may you can update your entrypoint
script to copy files to /var/www/html
all the time, but that may cause issues if you choose to scale the wordpress
layer.
My answer applied to the official docker wordpress image. So probably off topic but might help someone.
If you are using docker-compose
you can pull the latest image using this command.
docker pull wordpress
I believe this will update your core docker image. Any other local project which you docker-compose up -d
with this yml image setting as this will use the latest update.
services:
wordpress:
image: wordpress:latest
If you currently running the image will you need to docker-compose down
and docker-compose up -d
to invoke the update.
Thank you for your help. It worked. Here is the code i'm using.
I overriden the entrypoint in dockerfile
COPY check-wordpress-version.sh /usr/local/bin/
ENTRYPOINT ["check-wordpress-version.sh"]
Here is the content of check-wordpress-version.sh to check wordpress current version.
VOLUME_VERSION="$(php -r 'require('"'"'/var/www/html/wp-includes/version.php'"'"'); echo $wp_version;')"
echo "Volume version : "$VOLUME_VERSION
echo "WordPress version : "$WORDPRESS_VERSION
if [ $VOLUME_VERSION != $WORDPRESS_VERSION ]; then
echo "Forcing WordPress code update..."
rm -f /var/www/html/index.php
fi
docker-entrypoint.sh php-fpm
To expend on @Bigbenny's answer, my Dockerfile looked like the following:
FROM wordpress:latest
WORKDIR /var/www/html
COPY . /var/www/html
COPY check-wordpress-version.sh /usr/local/bin/
RUN chmod 755 /usr/local/bin/check-wordpress-version.sh
ENTRYPOINT ["/usr/local/bin/check-wordpress-version.sh"]
Two things to notice here:
chmod 755
the file or I would get a permissions denied error/usr/local/bin
because for some reason when I would just use ENTRYPOINT["check-wordpress-version.sh"]
, the file wouldn't be found by the container.I also, slightly tweaked the script to look like:
#!/bin/sh
VOLUME_VERSION="$(php -r 'require('"'"'/var/www/html/wp-includes/version.php'"'"'); echo $wp_version;')"
echo "Volume version : "$VOLUME_VERSION
echo "WordPress version : "$WORDPRESS_VERSION
if [ $VOLUME_VERSION != $WORDPRESS_VERSION ]; then
echo "Forcing WordPress code update..."
rm -f /var/www/html/index.php
rm -f /var/www/html/wp-includes/version.php
fi
docker-entrypoint.sh apache2-foreground
For my use-case, I had to use apache2-foreground
rather than php-fpm
; I also deleted the /var/www/html/wp-includes/version.php
file.
Finally, in my docker-compose, instead of the using the image
directive; I used build: ./wordpress
.
I hope this helps!
Wordpress seems to have addressed this under this issue.
I notice you are using a custom wp-config.php
. Most likely, you can use the WORDPRESS_CONFIG_EXTRA
for this rather than mounting wp-config.php
.
Theoretically (per the link above), updating the image should update the database, but I have not confirmed.
Based on this, my stack.yml
/docker-compose.yml
looks like this:
environment:
WORDPRESS_CONFIG_EXTRA: |
define( 'AUTOMATIC_UPDATER_DISABLED', true );
volumes:
- "./themes:/var/www/html/wp-content/themes/"
- "./plugins:/var/www/html/wp-content/plugins/"
- "./uploads:/var/www/html/wp-content/uploads/"