Docker image
I have installed WordPress with Docker guided by this tutorial:
https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-with-docker-compose
The tutorial is using this docker-compose.yml
file that is using wordpress:5.1.1-fpm-alpine
image:
version: '3'
services:
db:
image: mysql:8.0
container_name: db
...
wordpress:
depends_on:
- db
image: wordpress:5.1.1-fpm-alpine # <-- Note the WordPress version here
container_name: wordpress
...
Outdated WordPress version
Now, I have to install some plugins, but they are requiring some newer versions of the WordPress. Like the WP phpMyAdmin plugin:
This plugin doesn’t work with your version of WordPress. Please update WordPress.
The WordPress dashboard is displaying update notifications too:
WordPress 6.7.1 is available! Please update now.
Try to update
But when I click on the Please update now.
link, I receive this error:
You cannot update because WordPress 6.7.1 requires PHP version 7.2.24 or higher. You are running version 7.2.18.
Question
How can I reliably update the WordPress along with PHP? I don’t want to mess up the whole Docker setup.
2
Answers
Update by Docker image version
It didn't work
I updated the Docker images like this:
But, the website threw the
500
error:Bad restore
I had taken backups of Docker named volumes by this approach: https://stackoverflow.com/a/79247304/3405291
So, I did restore the Docker named volumes. However, the website threw this error:
Fix restore
The database connection error got fixed. To do so, I deleted everything inside the database volume by
rm -rf *
command:Then I restored the Docker volume of the database.
This screenshot shows the contents of the database volume before deleting/restoring and after:
As can be seen, before deleting everything, there were some extra files. Probably those files were messing around with the database connection.
Implication
The update by modifying the version of Docker images didn't work. But backup/restore helped us.
First and foremost, wordpress:5.1.1-fpm-alpine doesn’t seem to be an official WordPress image. These are always kind of hard to maintain, easy to set up, but a whole lot of headache to maintain. Anyway, to do such an upgrade, you will have to upgrade wordpress and php inside the container as well as their dependencies, goodluck with that! A better approach would be to create a backup of everthing (do a snapshot of the entire server if possible). Then run a new version of wordpress locally using a restored copy of the db, once everything works, you can use a newer image with that data.