Upgrade Moodle Docker

16 Sep 2024|2 minute read

I found out that upgrading moodle (running in a Docker container) is not as simple as doing docker pull image.

It requires some more steps, that are properly referenced in the Moodle’s documentation – version 4.4

Backing up Docker volumes

As always, backup everything before doing any kind of updates.

  1. Start by stopping the relevant Docker containers

    docker stop moodle mariadb
    
  2. Then, back up the Moodle volume (change according to your setup)

    docker run --rm -v ~/moodle-bak:/backups --volumes-from moodle busybox cp -a /bitnami/moodle /backups/latest
    

A quick commands explanation

Upgrading Moodle

As per documented, upgrading to the latest moodle version requires the following steps.

  1. Backup the existing Moodle folder
    Rename or move your current Moodle folder to a backup location (e.g., moodle-bak).

  2. Download and Extract the latest Moodle package
    Obtain the latest moodle.tgz file from the official Moodle sources and extract it.

  3. Restore critical files
    Copy essential configuration and custom files from your backup into the new Moodle directory:

    cp moodle-bak/config.php moodle
    cp -pr moodle.backup/theme/mytheme moodle/theme/mytheme
    cp -pr moodle.backup/mod/mymod moodle/mod/mymod
    
  4. Set ownership and permissions
    Update the file ownership and permissions as recommended:

    chown -R root:root moodle
    chmod -R 755 moodle
    

    On Debian Linux, you might consider creating a dedicated user for Moodle rather than using the web server user (e.g., www-data).

  5. Update Docker configuration
    In your new docker-compose file, replace the Docker volume with a bind mount that points to your Moodle directory on the host. This creates a persistent volume for the upgraded installation.

  6. Restart your containers
    Finally, start your Docker Compose setup to bring up the upgraded Moodle instance.

← The one before
Subscribe to Youtube RSS Feeds

Up next →
Sync KOReader with Dropbox