This project provides a lightweight and easy-to-use Docker image with an optional Docker Compose file to quickly spin up a Moodle instance for development, testing, or local evaluation purposes.
It is designed to be simpler and faster than the official Moodle development images, with no additional testing frameworks, no FPM, and no OPcache — just Apache + PHP with all necessary extensions pre-installed to support all common Moodle databases.
DO NOT USE IN ANY PRODUCTION ENVIROMENT
- Pre-installed PHP + Apache (no FPM, no OPcache).
- Supports PostgreSQL, MySQL/MariaDB, SQL Server, and Oracle out-of-the-box.
- Simple setup — just bind your Moodle directory.
- Docker Compose file included to easily manage services.
- Data persistence through Docker volumes.
- Exposes Moodle on port 8080 by default.
- Easy to run multiple instances simultaneously by adjusting project names and ports.
curl -o docker-compose.yml https://raw.githubusercontent.com/TuchSoft/phpmoodle/refs/heads/master/docker-compose.ymlor
wget https://raw.githubusercontent.com/TuchSoft/phpmoodle/refs/heads/master/docker-compose.ymlMake sure your Moodle codebase is available locally and ready to bind.
- Make sure the path to your local Moodle source (
./moodle) is correctly set. - Uncomment the database block you want to use (PostgreSQL, MySQL/MariaDB, SQL Server, Oracle).
docker-compose up -dRun the container manually:
docker run -d --name moodle-server \
-v $(pwd)/moodle:/var/www/html \
-p 8080:80 \
tuchsoft/phpmoodle:latestYou will need to manually configure your database separately if not using Docker Compose.
Open your browser at:
http://localhost:8080
Follow the installation wizard, and when prompted for database settings, use:
| Database | Host | User | Password | Port |
|---|---|---|---|---|
| PostgreSQL | database | moodle | moodle | 5432 |
| MySQL/MariaDB | database | moodle | moodle | 3306 |
| SQL Server | database | SA | moodle | 1433 |
| Oracle | oracle | moodle | moodle | 1521 |
The following volumes are defined to ensure your data is preserved across container restarts:
| Volume Name | Description |
|---|---|
moodle_data |
Moodle's moodledata directory (for file uploads, cache, etc.) |
db_data |
Database persistent storage |
To run multiple Moodle test environments simultaneously:
- Duplicate your project folder.
- Edit the
docker-compose.yml:- Change the
name:field at the top. - Bind to different ports (e.g., 8081:80, 5433:5432).
- Change the
- Launch both setups
- PostgreSQL is enabled by default.
- To use another database:
- Comment out the
PostgreSQLsection. - Uncomment the desired database section (
MySQL,SQL Server,Oracle).
- Comment out the
You can only enable one database container per instance at a time.
Oracle DB (supported up to Moodle versions ≤ 4.4:) requires a slight manual adjustment when installing :
- In your Moodle source folder, locate the file:
moodle/lib/dml/oci_native_moodle_package.sql - Prepend the following lines, replace occurrences of
$APP_USERwith your actual database username (typicallymoodle).CONNECT SYS/$APP_USER@FREEPDB1 AS SYSDBA; ALTER SESSION SET CURRENT_SCHEMA = $APP_USER; GRANT EXECUTE ON DBMS_LOCK TO PUBLIC;
- This step ensures correct package permissions during Oracle database initialization.
If using the provided compose setup that's all all you need to do, an automatic initialization is attempted by mounting a custom my-init.sql file into the Oracle container.
- Permission issues: Ensure the
moodlefolder and its contents have correct permissions for the container to access. - Ports already in use: Change the ports in
docker-compose.ymlif needed. - Database connection problems: Make sure the database service is fully initialized before starting Moodle installation.
👤 Mattia Bonzi @ TuchSoft mattia@tuchsoft.com
- Website: tuchsoft.com
- Github: @tuchsoft
Contributions, issues and feature requests are welcome!
Feel free to check the issues page.
