Moodle docker image based on Alpine Linux, NGINX, PHP-FPM and official Moodle
100K+
Moodle setup with high availability (HA) capabilities for Docker, build on Alpine Linux.
Repository: https://github.com/jimsihk/alpine-moodle
ARG_MOODLE_PLUGIN_LISTARG_MOODLE_GIT_URL and ARG_MOODLE_GIT_BRANCH at build time, MOODLE_GIT_URL and MOODLE_GIT_BRANCH at run time) when container startdocker logs -f <container name>)Moodle version and package dependencies are monitored and automatically updated through pull requests by Renovate: https://github.com/renovatebot/renovate
When Renovate updates the jimsihk/alpine-php-nginx base image in Dockerfile, GitHub Actions also refreshes the Alpine package pins in that same PR if the image moves to a new Alpine major/minor series.
A nightly build in GitHub Action scans for changes, then performs tagging and publishes a newer release on container registries.
The release tag will be in pattern: XXX.YYY.ZZ
version.php of Moodle sourcee.g. for Moodle 4.1.1+ branch 401 version 2022112801.06, the release tag number will be starting from 401.106.0
The images are available on multiple registries:
UPDATE_MOODLE_CODE)ARG_ENABLE_GIT_CLONE when buildStart the Docker containers:
docker compose up
Start a Moodle cluster:
./generate_ssl_cert.sh
docker compose --file docker-compose.replica.yml up
Login on the system using the provided credentials (ENV vars)
generate_ssl_cert.sh to generate a sample SSL certificate for localhostSESSION_CACHE_* environment variablesDefine the ENV variables in docker-compose.yml file
| Variable Name | Default | Description |
|---|---|---|
| LANG | en_US.UTF-8 | |
| LANGUAGE | en_US:en | |
| SITE_URL | http://localhost | Sets the public site URL |
| SSLPROXY | false | Disable SSL proxy to avoid site loop. e.g. Cloudflare |
| DB_TYPE | pgsql | mysqli - pgsql - mariadb |
| DB_HOST | postgres | Database hostname e.g. database container name |
| DB_PORT | 5432 | PostgresSQL=5432 - MySQL/MariaDB=3306 |
| DB_NAME | moodle | Database name |
| DB_USER | moodle | Database login username |
| DB_PASS | moodle | Database login password |
| DB_FETCHBUFFERSIZE | Set to 0 if using PostgresSQL poolers like PgBouncer in 'transaction' mode | |
| DB_DBHANDLEOPTIONS | false | Set to true if using PostgresSQL poolers like PgBouncer which does not support sending options |
| DB_DBPERSIST | false | Set to true to keep database connected with Moodle PHP thread while active, may have performance gain but may also used up database connections |
| DB_HOST_REPLICA | Database hostname of the read-only replica database | |
| DB_PORT_REPLICA | Database port of replica, left it empty to be same as DB_PORT | |
| DB_USER_REPLICA | Database login username of replica, left it empty to be same as DB_USER | |
| DB_PASS_REPLICA | Database login password of replica, left it empty to be same as DB_PASS | |
| DB_PREFIX | mdl_ | Database prefix. WARNING: don't use numeric values or Moodle won't start |
| MOODLE_EMAIL | [email protected] | |
| MOODLE_LANGUAGE | en | |
| MOODLE_SITENAME | New-Site | |
| MOODLE_SHORTNAME | moodle | |
| MOODLE_USERNAME | moodleuser | |
| MOODLE_PASSWORD | PLEASE_CHANGEME | |
| SMTP_HOST | smtp.gmail.com | |
| SMTP_PORT | 587 | |
| SMTP_USER | [email protected] | |
| SMTP_PASSWORD | your_password | |
| SMTP_PROTOCOL | tls | |
| MOODLE_MAIL_NOREPLY_ADDRESS | noreply@localhost | |
| MOODLE_MAIL_PREFIX | [moodle] | |
| memory_limit | 128M | Maximum amount of memory that a PHP script is allowed to allocate (default value inherited from base image) |
| client_max_body_size | 50M | Sets the maximum allowed size of the client request body, specified in the “Content-Length” request header field |
| post_max_size | 50M | Max size of post data allowed. This setting also affects file upload. To upload large files, this value must be larger than upload_max_filesize |
| upload_max_filesize | 50M | Maximum size of an uploaded file. |
| max_input_vars | 5000 | Maximum number of input variables allowed per request, set to at least 5000 |
| opcache_jit_buffer_size | 64M | Amount of shared memory to reserve for compiled JIT code, set to 0 to disable the JIT |
| opcache_jit | 1235 | Configure the JIT mode (default value inherited from base image) |
| opcache_memory_consumption | 128 | Size of the shared memory storage used by OPcache in megabytes (default value inherited from base image) |
| SESSION_CACHE_TYPE | Optionally sets shared session cache store: memcached, redis, database (leave it blank to keep unchanged) | |
| SESSION_CACHE_HOST | Hostname of the external cache store, required for memcached and redis | |
| SESSION_CACHE_PORT | Memcached=11211, Redis=6379, required for memcached and redis | |
| SESSION_CACHE_PREFIX | mdl | Cache prefix |
| SESSION_CACHE_AUTH | Authentication key for cache store, may be required for redis | |
| AUTO_UPDATE_MOODLE | true | Set to false to disable performing update of Moodle (e.g. plugins) at docker start |
| UPDATE_MOODLE_CODE | true | Set to false to disable auto download latest patch of Moodle core code, only effective if AUTO_UPDATE_MOODLE is true or built with ARG_ENABLE_GIT_CLONE as true |
| DISABLE_WEB_INSTALL_PLUGIN | false | Set to true to disable plugin installation via site admin UI, could be useful to avoid image outsync with HA setting |
| MAINT_STATUS_KEYWORD | Status: enabled | Keyword for detecting Moodle maintenance status when running admin/cli/maintenance.php, language following the Moodle site default language |
| LOCAL_CACHE_DIRECTORY | Set the path to a local fast filesystem for Moodle local caching that no need to be shared with other instances | |
| SKIP_MOODLE_CONFIG | false | Set to true to skip the Moodle configuration script |
More settings on PHP and NGINX can refer to the base image https://github.com/jimsihk/alpine-php-nginx/blob/dev/README.md
AUTO_UPDATE_MOODLE and UPDATE_MOODLE_CODEIf set to true, Moodle will be set to CLI maintenance mode at container start while performing the update. No user will be able to use Moodle, not even admin.
If a cluster of Moodle containers are deployed for HA (e.g. on Kubernetes), it is suggested to set both to false to avoid unexpected interruption to users when auto scaling, such as adding extra containers to the cluster or container restart for auto healing.
ARG_MOODLE_PLUGIN_LIST: define the list of pluginsARG_MOODLE_PLUGIN_LIST:docker buildx build . -t my_moodle_image:my_tag \
--build-arg ARG_MOODLE_PLUGIN_LIST='mod_attendance mod_checklist mod_customcert block_checklist gradeexport_checklist'
Dockerfile.plugins:# Dockerfile.plugins
FROM quay.io/jimsihk/alpine-moodle:latest
# Install additional plugins, a space/comma separated arg, (optional)
# Run install-plugin-list with argument "-f" to force install
# if the plugin is not compatible with current Moodle version
ARG ARG_MOODLE_PLUGIN_LIST=''
ENV MOODLE_PLUGIN_LIST=${ARG_MOODLE_PLUGIN_LIST}
RUN if [ -n "${MOODLE_PLUGIN_LIST}" ]; then /usr/libexec/moodle/install-plugin-list -p "${MOODLE_PLUGIN_LIST}"; fi && \
rm -rf /tmp/moodle-plugins
# Dockerfile.plugins
FROM quay.io/jimsihk/alpine-moodle:latest
# Install additional plugins, a space/comma separated arg, (optional)
ARG ARG_MOODLE_PLUGIN_LIST=''
ENV MOODLE_PLUGIN_LIST=${ARG_MOODLE_PLUGIN_LIST}
RUN /usr/libexec/moodle/download-moodle-plugin
Dockerfile.plugins:# Build
docker buildx build . -t my_moodle_image:my_tag \
-f Dockerfile.plugins \
--build-arg ARG_MOODLE_PLUGIN_LIST='mod_attendance,mod_checklist,mod_customcert,block_checklist,gradeexport_checklist'
ARG_ALLOW_INCOMPATIBLE_PLUGIN: allow installing incompatible pluginsARG_ALLOW_INCOMPATIBLE_PLUGIN is also available to easily control if continue the installation of latest available version despite lack of compatibility from maturity, default as false:docker buildx build . -t my_moodle_image:my_tag \
--build-arg ARG_MOODLE_PLUGIN_LIST='mod_attendance mod_checklist mod_customcert block_checklist gradeexport_checklist' \
--build-arg ARG_ALLOW_INCOMPATIBLE_PLUGIN='true'
Dockerfile.plugins:# Dockerfile.plugins
FROM quay.io/jimsihk/alpine-moodle:latest
ARG ARG_MOODLE_PLUGIN_LIST='mod_attendance mod_checklist mod_customcert block_checklist gradeexport_checklist'
ARG ARG_ALLOW_INCOMPATIBLE_PLUGIN='true'
ENV MOODLE_PLUGIN_LIST=${ARG_MOODLE_PLUGIN_LIST}
ENV ALLOW_INCOMPATIBLE_PLUGIN=${ARG_ALLOW_INCOMPATIBLE_PLUGIN}
RUN /usr/libexec/moodle/download-moodle-plugin
role-update-capability command, but beware that only version 0.39 of the plugin has this commandContent type
Image
Digest
sha256:70a41466e…
Size
100.3 MB
Last updated
5 days ago
docker pull jimsihk/alpine-moodle:latest-slim