How to update WordPress & PHP when they are installed by Docker

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:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>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
...
</code>
<code>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 ... </code>
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.

7

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.

2

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: /a/79247304/3405291

So, I did restore the Docker named volumes. However, the website threw this error:

Error establishing a database connection

Fix restore

The database connection error got fixed. To do so, I deleted everything inside the database volume by rm -rf * command:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>/var/lib/docker/volumes/wordpress_dbdata/_data/
</code>
<code>/var/lib/docker/volumes/wordpress_dbdata/_data/ </code>
/var/lib/docker/volumes/wordpress_dbdata/_data/

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.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật