{"id":23626339,"url":"https://github.com/yetanalytics/moodle-docker","last_synced_at":"2025-11-07T17:30:41.050Z","repository":{"id":259118205,"uuid":"781181027","full_name":"yetanalytics/moodle-docker","owner":"yetanalytics","description":"Yet Moodle Docker","archived":false,"fork":false,"pushed_at":"2024-04-03T16:06:41.000Z","size":296,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-27T23:13:26.429Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yetanalytics.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-04-02T22:31:04.000Z","updated_at":"2024-10-21T19:54:25.000Z","dependencies_parsed_at":"2024-10-22T22:44:21.839Z","dependency_job_id":null,"html_url":"https://github.com/yetanalytics/moodle-docker","commit_stats":null,"previous_names":["yetanalytics/moodle-docker"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yetanalytics%2Fmoodle-docker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yetanalytics%2Fmoodle-docker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yetanalytics%2Fmoodle-docker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yetanalytics%2Fmoodle-docker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yetanalytics","download_url":"https://codeload.github.com/yetanalytics/moodle-docker/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239533839,"owners_count":19654770,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-27T22:53:00.385Z","updated_at":"2025-11-07T17:30:41.006Z","avatar_url":"https://github.com/yetanalytics.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# moodle-docker: Docker Containers for Moodle Developers\n[![Build Status](https://github.com/moodlehq/moodle-docker/workflows/moodle-docker%20CI/badge.svg?branch=main)](https://github.com/moodlehq/moodle-docker/actions/workflows/ci.yml?query=branch%3Amain)\n\nThis repository contains Docker configuration aimed at Moodle developers and testers to easily deploy a testing environment for Moodle.\n\n## Features:\n* All supported database servers (PostgreSQL, MySQL, Micosoft SQL Server, Oracle XE)\n* Behat/Selenium configuration for Firefox and Chrome\n* Catch-all smtp server and web interface to messages using [Mailpit](https://github.com/axllent/mailpit)\n* All PHP Extensions enabled configured for external services (e.g. solr, ldap)\n* All supported PHP versions\n* Zero-configuration approach\n* Backed by [automated tests](https://travis-ci.com/moodlehq/moodle-docker/branches)\n\n## Prerequisites\n* [Docker](https://docs.docker.com) and [Docker Compose](https://docs.docker.com/compose/cli-command/#installing-compose-v2) installed if your Docker CLI version does not support `docker compose` command.\n* It's recommended to always run the latest versions of each, but at the minimum Docker v20.10.15 and Docker Compose v2.5.0 should be used.\n* 3.25GB of RAM (if you choose [Microsoft SQL Server](https://docs.microsoft.com/en-us/sql/linux/sql-server-linux-setup#prerequisites) as db server)\n\n## Quick start\n\n```bash\n# Set up path to Moodle code\nexport MOODLE_DOCKER_WWWROOT=/path/to/moodle/code\n# Choose a db server (Currently supported: pgsql, mariadb, mysql, mssql, oracle)\nexport MOODLE_DOCKER_DB=pgsql\n\n# Ensure customized config.php for the Docker containers is in place\ncp config.docker-template.php $MOODLE_DOCKER_WWWROOT/config.php\n\n# Start up containers\nbin/moodle-docker-compose up -d\n\n# Wait for DB to come up (important for oracle/mssql)\nbin/moodle-docker-wait-for-db\n\n# Work with the containers (see below)\n# [..]\n\n# Shut down and destroy containers\nbin/moodle-docker-compose down\n```\n## Run several Moodle instances\n\nBy default, the script will load a single instance. If you want to run two\nor more different versions of Moodle at the same time, you have to add this\nenvironment variable prior running any of the steps at `Quick start`:\n\n```bash\n# Define a project name; it will appear as a prefix on container names.\nexport COMPOSE_PROJECT_NAME=moodle34\n\n# Use a different public web port from those already taken\nexport MOODLE_DOCKER_WEB_PORT=1234\n\n# [..] run all \"Quick steps\" now\n```\n\nHaving set up several Moodle instances, you need to have set up\nthe environment variable `COMPOSE_PROJECT_NAME` to just refer\nto the instance you expect to. See\n[envvars](https://docs.docker.com/compose/reference/envvars/)\nto see more about `docker-compose` environment variables.\n\n## Use containers for running behat tests\n\n```bash\n# Initialize behat environment\nbin/moodle-docker-compose exec webserver php admin/tool/behat/cli/init.php\n# [..]\n\n# Run behat tests\nbin/moodle-docker-compose exec -u www-data webserver php admin/tool/behat/cli/run.php --tags=@auth_manual\nRunning single behat site:\nMoodle 3.4dev (Build: 20171006), 33a3ec7c9378e64c6f15c688a3c68a39114aa29d\nPhp: 7.1.9, pgsql: 9.6.5, OS: Linux 4.9.49-moby x86_64\nServer OS \"Linux\", Browser: \"firefox\"\nStarted at 25-05-2017, 19:04\n...............\n\n2 scenarios (2 passed)\n15 steps (15 passed)\n1m35.32s (41.60Mb)\n```\n\nNotes:\n\n* The behat faildump directory is exposed at http://localhost:8000/_/faildumps/.\n* Use `MOODLE_DOCKER_BROWSER` to switch the browser you want to run the test against.\n  You need to recreate your containers using `bin/moodle-docker-compose` as described below, if you change it.\n\n## Use containers for running phpunit tests\n\n```bash\n# Initialize phpunit environment\nbin/moodle-docker-compose exec webserver php admin/tool/phpunit/cli/init.php\n# [..]\n\n# Run phpunit tests\n\nbin/moodle-docker-compose exec webserver vendor/bin/phpunit auth/manual/tests/manual_test.php\nMoodle 4.0.4 (Build: 20220912), ef7a51dcb8e805a6889974b04d3154ba8bd874f2\nPhp: 7.3.33, pgsql: 11.15 (Debian 11.15-1.pgdg90+1), OS: Linux 5.10.0-11-amd64 x86_64\nPHPUnit 9.5.13 by Sebastian Bergmann and contributors.\n\n..                                                                  2 / 2 (100%)\n\nTime: 00:00.304, Memory: 72.50 MB\n\nOK (2 tests, 7 assertions)\n```\n\nNotes:\n* If you want to run tests with code coverage reports:\n```\n# Build component configuration\nbin/moodle-docker-compose exec webserver php admin/tool/phpunit/cli/util.php --buildcomponentconfigs\n# Execute tests for component\nbin/moodle-docker-compose exec webserver php -d pcov.enabled=1 -d pcov.directory=. vendor/bin/phpunit --configuration reportbuilder --coverage-text\n```\n* See available [Command-Line Options](https://phpunit.readthedocs.io/en/9.5/textui.html#textui-clioptions) for further info\n\n## Use containers for manual testing\n\n```bash\n# Initialize Moodle database for manual testing\nbin/moodle-docker-compose exec webserver php admin/cli/install_database.php --agree-license --fullname=\"Docker moodle\" --shortname=\"docker_moodle\" --summary=\"Docker moodle site\" --adminpass=\"test\" --adminemail=\"admin@example.com\"\n```\n\nNotes:\n* Moodle is configured to listen on `http://localhost:8000/`.\n* Mailpit is listening on `http://localhost:8000/_/mail` to view emails which Moodle has sent out.\n* The admin `username` you need to use for logging in is `admin` by default. You can customize it by passing `--adminuser='myusername'`\n* During manual testing, if you are facing that your Moodle site is logging\n you off continuously, putting the correct credentials, clean all cookies\n for your Moodle site URL (usually `localhost`) from your browser.\n [More info](https://github.com/moodlehq/moodle-docker/issues/256).\n\n## Use containers for running behat tests for the Moodle App\n\nIn order to run Behat tests for the Moodle App, you need to install the [local_moodleappbehat](https://github.com/moodlehq/moodle-local_moodleappbehat) plugin in your Moodle site. Everything else should be the same as running standard Behat tests for Moodle. Make sure to filter tests using the `@app` tag.\n\nThe Behat tests will be run against a container serving the mobile application, you have two options here:\n\n1. Use a Docker image that includes the application code. You need to specify the `MOODLE_DOCKER_APP_VERSION` env variable and the [moodlehq/moodleapp](https://hub.docker.com/r/moodlehq/moodleapp) image will be downloaded from Docker Hub. You can read about the available images in [Moodle App Docker Images](https://moodledev.io/general/app/development/setup/docker-images) (for Behat, you'll want to run the ones with the `-test` suffix).\n\n2. Use a local copy of the application code and serve it through Docker, similar to how the Moodle site is being served. Set the `MOODLE_DOCKER_APP_PATH` env variable to the codebase in you file system. This will assume that you've already initialized the app calling `npm install` locally.\n\nFor both options, you also need to set `MOODLE_DOCKER_BROWSER` to \"chrome\".\n\n```bash\n# Install local_moodleappbehat plugin\ngit clone https://github.com/moodlehq/moodle-local_moodleappbehat \"$MOODLE_DOCKER_WWWROOT/local/moodleappbehat\"\n\n# Initialize behat environment\nbin/moodle-docker-compose exec webserver php admin/tool/behat/cli/init.php\n# (you should see \"Configured app tests for version X.X.X\" here)\n\n# Run behat tests\nbin/moodle-docker-compose exec -u www-data webserver php admin/tool/behat/cli/run.php --tags=\"@app\u0026\u0026@mod_login\"\nRunning single behat site:\nMoodle 4.0dev (Build: 20200615), a2b286ce176fbe361f0889abc8f30f043cd664ae\nPhp: 7.2.30, pgsql: 11.8 (Debian 11.8-1.pgdg90+1), OS: Linux 5.3.0-61-generic x86_64\nServer OS \"Linux\", Browser: \"chrome\"\nBrowser specific fixes have been applied. See http://docs.moodle.org/dev/Acceptance_testing#Browser_specific_fixes\nStarted at 13-07-2020, 18:34\n.....................................................................\n\n4 scenarios (4 passed)\n69 steps (69 passed)\n3m3.17s (55.02Mb)\n```\n\nIf you are going with the second option, this *can* be used for local development of the Moodle App, given that the `moodleapp` container serves the app on the local 8100 port. However, this is intended to run Behat tests that require interacting with a local Moodle environment. Normal development should be easier calling `npm start` in the host system.\n\nBy all means, if you don't want to have npm installed locally you can go full Docker executing the following commands before starting the containers:\n\n```\ndocker run --volume $MOODLE_DOCKER_APP_PATH:/app --workdir /app bash -c \"npm install\"\n```\n\nYou can learn more about writing tests for the app in [Acceptance testing for the Moodle App](https://moodledev.io/general/app/development/testing/acceptance-testing).\n\n## Using VNC to view behat tests\n\nIf `MOODLE_DOCKER_SELENIUM_VNC_PORT` is defined, selenium will expose a VNC session on the port specified so behat tests can be viewed in progress.\n\nFor example, if you set `MOODLE_DOCKER_SELENIUM_VNC_PORT` to 5900..\n1. Download a VNC client: https://www.realvnc.com/en/connect/download/viewer/\n2. With the containers running, enter 0.0.0.0:5900 as the port in VNC Viewer. You will be prompted for a password. The password is 'secret'.\n3. You should be able to see an empty Desktop. When you run any [Javascript requiring Behat tests](https://moodledev.io/general/development/tools/behat#javascript) (e.g. those tagged `@javascript`) a browser will popup and you will see the tests execute.\n\n## Stop and restart containers\n\n`bin/moodle-docker-compose down` which was used above after using the containers stops and destroys the containers. If you want to use your containers continuously for manual testing or development without starting them up from scratch everytime you use them, you can also just stop without destroying them. With this approach, you can restart your containers sometime later, they will keep their data and won't be destroyed completely until you run `bin/moodle-docker-compose down`.\n\n```bash\n# Stop containers\nbin/moodle-docker-compose stop\n\n# Restart containers\nbin/moodle-docker-compose start\n```\n\n## Environment variables\n\nYou can change the configuration of the docker images by setting various environment variables **before** calling `bin/moodle-docker-compose up`.\nWhen you change them, use `bin/moodle-docker-compose down \u0026\u0026 bin/moodle-docker-compose up -d` to recreate your environment.\n\n| Environment Variable                      | Mandatory | Allowed values                        | Default value | Notes                                                                        |\n|-------------------------------------------|-----------|---------------------------------------|---------------|------------------------------------------------------------------------------|\n| `MOODLE_DOCKER_DB`                        | yes       | pgsql, mariadb, mysql, mssql, oracle  | none          | The database server to run against                                           |\n| `MOODLE_DOCKER_WWWROOT`                   | yes       | path on your file system              | none          | The path to the Moodle codebase you intend to test                           |\n| `MOODLE_DOCKER_DB_VERSION`                | no        | Docker tag - see relevant database page on docker-hub | mysql: 8.0 \u003cbr/\u003epgsql: 13 \u003cbr/\u003emariadb: 10.7 \u003cbr/\u003emssql: 2017-latest \u003cbr/\u003eoracle: 21| The database server docker image tag |\n| `MOODLE_DOCKER_PHP_VERSION`               | no        | 8.1, 8.0, 7.4, 7.3, 7.2, 7.1, 7.0, 5.6| 8.1           | The php version to use                                                       |\n| `MOODLE_DOCKER_BROWSER`                   | no        | firefox, chrome,  firefox:\u0026lt;tag\u0026gt;, chrome:\u0026lt;tag\u0026gt; | firefox:3       | The browser to run Behat against. Supports a colon notation to specify a specific Selenium docker image version to use. e.g. firefox:2.53.1 can be used to run with older versions of Moodle (\u003c3.5)              |\n| `MOODLE_DOCKER_PHPUNIT_EXTERNAL_SERVICES` | no        | any value                             | not set       | If set, dependencies for memcached, redis, solr, and openldap are added      |\n| `MOODLE_DOCKER_BBB_MOCK`                  | no        | any value                             | not set       | If set the BigBlueButton mock image is started and configured                |\n| `MOODLE_DOCKER_MATRIX_MOCK`               | no        | any value                             | not set       | If set the Matrix mock image is started and configured                       |\n| `MOODLE_DOCKER_BEHAT_FAILDUMP`            | no        | Path on your file system              | not set       | Behat faildumps are already available at http://localhost:8000/_/faildumps/ by default, this allows for mapping a specific filesystem folder to retrieve the faildumps in bulk / automated ways |\n| `MOODLE_DOCKER_DB_PORT`                   | no        | any integer value                     | none          | If you want to bind to any host IP different from the default 127.0.0.1, you can specify it with the bind_ip:port format (0.0.0.0 means bind to all). Username is \"moodle\" (or \"sa\" for mssql) and password is \"m@0dl3ing\". |\n| `MOODLE_DOCKER_WEB_HOST`                  | no        | any valid hostname                    | localhost     | The hostname for web                                |\n| `MOODLE_DOCKER_WEB_PORT`                  | no        | any integer value (or bind_ip:integer)| 127.0.0.1:8000| The port number for web. If set to 0, no port is used.\u003cbr/\u003eIf you want to bind to any host IP different from the default 127.0.0.1, you can specify it with the bind_ip:port format (0.0.0.0 means bind to all) |\n| `MOODLE_DOCKER_SELENIUM_VNC_PORT`         | no        | any integer value (or bind_ip:integer)| not set       | If set, the selenium node will expose a vnc session on the port specified. Similar to MOODLE_DOCKER_WEB_PORT, you can optionally define the host IP to bind to. If you just set the port, VNC binds to 127.0.0.1 |\n| `MOODLE_DOCKER_APP_PATH`                  | no        | path on your file system              | not set       | If set and the chrome browser is selected, it will start an instance of the Moodle app from your local codebase |\n| `MOODLE_DOCKER_APP_VERSION`               | no        | a valid [app docker image version](https://docs.moodle.org/dev/Moodle_App_Docker_images) | not set       | If set will start an instance of the Moodle app if the chrome browser is selected |\n\n## Local customisations\n\nIn some situations you may wish to add local customisations, such as including additional containers, or changing existing containers.\n\nThis can be accomplished by specifying a `local.yml`, which will be added in and loaded with the existing yml configuration files automatically. For example:\n\n``` file=\"local.yml\"\nversion: \"2\"\nservices:\n\n  # Add the adminer image at the latest tag on port 8080:8080\n  adminer:\n    image: adminer:latest\n    restart: always\n    ports:\n      - 8080:8080\n    depends_on:\n      - \"db\"\n\n  # Modify the webserver image to add another volume:\n  webserver:\n    volumes:\n      - \"/opt/data:/opt/data:cached\"\n```\n\n## Using XDebug for live debugging\n\nThe XDebug PHP Extension is not included in this setup and there are reasons not to include it by default.\n\nHowever, if you want to work with XDebug, especially for live debugging, you can add XDebug to a running webserver container easily:\n\n```\n# Install XDebug extension with PECL\nmoodle-docker-compose exec webserver pecl install xdebug\n\n# Set some wise setting for live debugging - change this as needed\nread -r -d '' conf \u003c\u003c'EOF'\n; Settings for Xdebug Docker configuration\nxdebug.mode = debug\nxdebug.client_host = host.docker.internal\n; Some IDEs (eg PHPSTORM, VSCODE) may require configuring an IDE key, uncomment if needed\n; xdebug.idekey=MY_FAV_IDE_KEY\nEOF\nmoodle-docker-compose exec webserver bash -c \"echo '$conf' \u003e\u003e /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini\"\n\n# Enable XDebug extension in Apache and restart the webserver container\nmoodle-docker-compose exec webserver docker-php-ext-enable xdebug\nmoodle-docker-compose restart webserver\n```\n\nWhile setting these XDebug settings depending on your local need, please take special care of the value of `xdebug.client_host` which is needed to connect from the container to the host. The given value `host.docker.internal` is a special DNS name for this purpose within Docker for Windows and Docker for Mac. If you are running on another Docker environment, you might want to try the value `localhost` instead or even set the hostname/IP of the host directly. Please turn off the firewall or open the port used in the `xdebug.client_port`.\n\nOpen the port (9003 is the default one) by using the example command for Linux Ubuntu:\n```\nsudo ufw allow 9003\n```\n\n\nAfter these commands, XDebug ist enabled and ready to be used in the webserver container.\nIf you want to disable and re-enable XDebug during the lifetime of the webserver container, you can achieve this with these additional commands:\n\n```\n# Disable XDebug extension in Apache and restart the webserver container\nmoodle-docker-compose exec webserver sed -i 's/^zend_extension=/; zend_extension=/' /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini\nmoodle-docker-compose restart webserver\n\n# Enable XDebug extension in Apache and restart the webserver container\nmoodle-docker-compose exec webserver sed -i 's/^; zend_extension=/zend_extension=/' /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini\nmoodle-docker-compose restart webserver\n```\n\n## Advanced usage\n\nAs can be seen in [bin/moodle-docker-compose](https://github.com/moodlehq/moodle-docker/blob/main/bin/moodle-docker-compose),\nthis repo is just a series of Docker Compose configurations and light wrapper which make use of companion docker images. Each part\nis designed to be reusable and you are encouraged to use the docker [compose] commands as needed.\n\n## Quick start with Gitpod\n\nGitpod is a free, cloud-based, development environment providing VS Code and a suitable development environment right in your browser.\n\nWhen launching a workspace in Gitpod, it will automatically:\n\n* Clone the Moodle repo into the `\u003cworkspace\u003e/moodle` folder.\n* Initialise the Moodle database.\n* Start the Moodle webserver.\n\n\u003cp\u003e\n    \u003ca href=\"https://gitpod.io/#https://github.com/moodlehq/moodle-docker\" target=\"_blank\" rel=\"noopener noreferrer\"\u003e\n        \u003cimg loading=\"lazy\" src=\"https://gitpod.io/button/open-in-gitpod.svg\" alt=\"Open in Gitpod\" class=\"img_ev3q\"\u003e\n    \u003c/a\u003e\n\u003c/p\u003e\n\n\u003e **IMPORTANT**: Gitpod is an alternative to local development and completely optional. We recommend setting up a local development environment if you plan to contribute regularly.\n\nThe Moodle Gitpod template supports the following environment variables:\n\n* `MOODLE_REPOSITORY`. The Moodle repository to be cloned. The value should be URL encoded. If left undefined, the default repository `https://github.com/moodle/moodle.git` is used.\n* `MOODLE_BRANCH`. The Moodle branch to be cloned. If left undefined, the default branch `main` is employed.\n\nFor a practical demonstration, launch a Gitpod workspace with the 'main' branch patch for [MDL-79912](https://tracker.moodle.org/browse/MDL-79912). Simply open the following URL in your web browser (note that MOODLE_REPOSITORY should be URL encoded). The password for the admin user is **test**:\n\n```\nhttps://gitpod.io/#MOODLE_REPOSITORY=https%3A%2F%2Fgithub.com%2Fsarjona%2Fmoodle.git,MOODLE_BRANCH=MDL-79912-main/https://github.com/moodlehq/moodle-docker\n```\n\nTo optimize your browsing experience, consider integrating the [Tampermonkey extension](https://www.tampermonkey.net/) into your preferred web browser for added benefits. Afterward, install the Gitpod script, which can be accessed via the following URL: [Gitpod script](https://gist.githubusercontent.com/sarjona/9fc728eb2d2b41a783ea03afd6a6161e/raw/gitpod.js). This script efficiently incorporates a button adjacent to each branch within the Moodle tracker, facilitating the effortless initiation of a Gitpod workspace tailored to the corresponding patch for the issue you're currently viewing.\n\n## Companion docker images\n\nThe following Moodle customised docker images are close companions of this project:\n\n* [moodle-php-apache](https://github.com/moodlehq/moodle-php-apache): Apache/PHP Environment preconfigured for all Moodle environments\n* [moodle-db-mssql](https://github.com/moodlehq/moodle-db-mssql): Microsoft SQL Server for Linux configured for Moodle\n* [moodle-db-oracle](https://github.com/moodlehq/moodle-db-oracle): Oracle XE configured for Moodle\n\n## Contributions\n\nAre extremely welcome!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyetanalytics%2Fmoodle-docker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyetanalytics%2Fmoodle-docker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyetanalytics%2Fmoodle-docker/lists"}