Tim
Tim

Reputation: 715

Wordpress docker container - help enabling automatic plugin and theme updates

I’ve successfully installed Wordpress using Docker. Almost everything works, including manual updates of plugins and themes in the Wordpress admin console, which shows that file permissions are correct. What I’m having trouble with is getting Wordpress automatic plugin and theme updates to work. Automatic plugin and theme updates work on my non-docker hosted Wordpress instances.

I use bind mounts so that my persistent data is persisted onto the local file system. I prefer these to docker volumes, mostly because I understand file systems better than docker volumes. This is set up so that the docker container provides the core Wordpress files, and the bind mount provides the wp-content folder. This means Wordpress core updates are easy - I just update the container image and the core files are replaced - they’re never written to a local file system, they stay in the container.

I can get the Wordpress CLI to do updates using a cron job. It's inelegant because I need a full deployment of Wordpress including a working wp-config file on my file system, as well as in the docker container. I would prefer to get Wordpress controlled automatic updates working.

I’ve spent many hours searching the internet, reading Stack Exchange, reading what I can find. I’ve tried calling the wordpress cron PHP script manually. I’m about out of ideas to get this to work properly, I’d appreciate some help :slight_smile:

This screenshot shows there are updates available, automatic updates are enabled, and that manual updates from the Wordpress console works.

Wordpress docker manual updates work

Here's my docker compose file

services:
  wordpress:
    container_name: wordpress
    image: wordpress:php8.3-apache
    restart: unless-stopped
    environment:
      TZ: Pacific/Auckland
      WORDPRESS_DB_HOST: (removed)
      WORDPRESS_DB_NAME: (removed)
      WORDPRESS_DB_USER: (removed)
      WORDPRESS_DB_PASSWORD: (removed)
    ports:
      # Make available to reverse proxy
      - '8081:80'
    volumes:
      # Map wordpress content folder, but use Wordpress from the conatiner
      - /var/www/wordpress/wp-content/:/var/www/html/wp-content/
      # Apache2 configuration
      - /docker/wordpress/conf/apache/mpm_prefork.conf:/etc/apache2/mods-available/mpm_prefork.conf
      # PHP configuration
      - /docker/wordpress/conf/php/php.ini-production:/usr/local/etc/php/php.ini
      # Allow apache logs to be written to the host file system
      - /var/log/apache2/:/var/log/apache2/
      # Allow php logs to be written to the host file system
      - /var/log/php/:/var/log/php/
      # Allow uploads
      - /docker/wordpress/conf/php/uploads.ini:/usr/local/etc/php/conf.d/uploads.ini

Upvotes: 0

Views: 135

Answers (1)

Sebastian Kübeck
Sebastian Kübeck

Reputation: 196

The official docker container does not start cron so no cron jobs are executed and hence no updates are installed. You have basically two options:

  1. Use a container that has a cron running alongside the web server, such as this: https://github.com/sebastian-kuebeck/wordpress-container
  2. Use a separate container that just runs the cron job and triggers updates in the wordpress container: How to run a cron job inside a docker container?

Upvotes: 0

Related Questions