Sign inSign up

ellakcy/moodle

By ellakcy

•Updated 5 months ago

A complete moodle installation with preinstalled admin user and automatic database setup.

Image
Security
Integration & delivery
Content management system
12

100K+

ellakcy/moodle repository overview

⁠docker-moodle

A Docker image that installs and runs the latest Moodle stable, with external MySQL, Mariadb or Postgresql Database and automated installation with a default predefined administrator user. Also all the images are availalbe via docker hub⁠.

⁠Buidling

Buidling the required images using this repo is a liitle laborious and the whole process is described in the CONTRIBUTING.md file.

⁠Available Images

All available images are listed in: https://hub.docker.com/r/ellakcy/moodle/tags?page=1&ordering=-name⁠

Each flavor is seperates by database support, version and either if is it based on apache, or alpine via fpm. To be more specific:

Image naming PatternPHP execution typeMysql SupportMariadb SupportPostgresql Support
mulitbase_apache_^VERSION^apacheYESYESYES
mysql_maria_apache_^VERSION^apacheYESYESNO
postgresql_apache_^VERSION^apacheNONOYES
mulitbase_alpine_fpm_^VERSION^fpm (running on alpine linux)YESYESYES
mysql_maria_alpine_fpm_^VERSION^fpm (running on alpine linux)YESYESNO
postgresql_alpine_fpm_^VERSION^fpm (running on alpine linux)NONOYES
mulitbase_fpm_^VERSION^fpmYESYESYES
mysql_maria_fpm_^VERSION^fpmYESYESNO
postgresql_fpm_^VERSION^fpmNONOYES

The ^VERSION^ is a 2-3 digit number the first digit follows the major version and the rest of them follow the minor version for example the mulitbase_apache_39 runs the moodle 3.9 whilst mulitbase_apache_310 runs the moodle 3.10 .

Also for the latest moodle version we also ship the following images:

ImagePHP execution typeMysql SupportMariadb SupportPostgresql Support
latestapacheYESYESYES
mulitbase_apache_latestapacheYESYESYES
mysql_maria_apache_latestapacheYESYESNO
postgresql_apache_latestapacheNONOYES
mulitbase_alpine_fpm_latestfpm (running on alpine linux)YESYESYES
mysql_maria_alpine_fpm_latestfpm (running on alpine linux)YESYESNO
postgresql_alpine_fpm_latestfpm (running on alpine linux)NONOYES
mulitbase_fpm_latestfpmYESYESYES
mysql_maria_fpm_latestfpmYESYESNO
postgresql_fpm_latestfpmNONOYES

Whilst for the most recent moodle lts we ship:

ImagePHP execution typeMysql SupportMariadb SupportPostgresql Support
mulitbase_apache_ltsapacheYESYESYES
mysql_maria_apache_ltsapacheYESYESNO
postgresql_apache_ltsapacheNONOYES
mulitbase_alpine_fpm_ltsfpm (running on alpine linux)YESYESYES
mysql_maria_alpine_fpm_ltsfpm (running on alpine linux)YESYESNO
postgresql_alpine_fpm_ltsfpm (running on alpine linux)NONOYES
mulitbase_fpm_ltsfpmYESYESYES
mysql_maria_fpm_ltsfpmYESYESNO
postgresql_fpm_ltsfpmNONOYES

All images are shipped with php 7.4 .

⁠PHP 8.0 images

Default php is 7.4 whereas images with php 8.0 are shipped as well for moodle versions 3.11, 4.0 and 4.11 php is shipped as well:

Image naming PatternPHP execution typeMysql SupportMariadb SupportPostgresql Support
mulitbase_apache_php8.0_^VERSION^apacheYESYESYES
mysql_maria_apache_php8.0_^VERSION^apacheYESYESNO
postgresql_apache_php8.0_^VERSION^apacheNONOYES
mulitbase_alpine_fpm_php8.0_^VERSION^fpm (running on alpine linux)YESYESYES
mysql_maria_alpine_fpm_php8.0_^VERSION^fpm (running on alpine linux)YESYESNO
postgresql_alpine_fpm_php8.0_^VERSION^fpm (running on alpine linux)NONOYES
mulitbase_fpm_php8.0_^VERSION^fpmYESYESYES
mysql_maria_fpm_php8.0_^VERSION^fpmYESYESNO
postgresql_fpm_php8.0_^VERSION^fpmNONOYES

For php 7.4 images use the following

Image naming PatternPHP execution typeMysql SupportMariadb SupportPostgresql Support
mulitbase_apache_php7.4_^VERSION^apacheYESYESYES
mysql_maria_apache_php7.4_^VERSION^apacheYESYESNO
postgresql_apache_php7.4_^VERSION^apacheNONOYES
mulitbase_alpine_fpm_php7.4_^VERSION^fpm (running on alpine linux)YESYESYES
mysql_maria_alpine_fpm_php7.4_^VERSION^fpm (running on alpine linux)YESYESNO
postgresql_alpine_fpm_php7.4_^VERSION^fpm (running on alpine linux)NONOYES
mulitbase_fpm_php7.4_^VERSION^fpmYESYESYES
mysql_maria_fpm_php7.4_^VERSION^fpmYESYESNO
postgresql_fpm_php7.4_^VERSION^fpmNONOYES

⁠Supported Database Versions:

The images support the following version for each database:

  • Postgresql: 11 or earlier
  • Mysql: 5.7
  • Mariadb: 10.2

⁠Build Cycle and build versions

We aim to deliver freshly images on weekly basis. Each build image is tagged with the build date in a format _YmdHi, without build date is the latest build, for example the image mysql_maria_apache_latest is the latest built image whilst mysql_maria_apache_latest_202108112012 is the image built at 2021-08-11 20:12. At docker hub you can look at tags⁠ section for the latest or older builds.

⁠Run

We also developed a docker-compose⁠ solution. We strongly reccomend using this one.

Furthermore we also strongly recomend to create a docker-compose.yml and run using docker-compose in case that our solution mentioned above, does not fit your needs.

⁠Running images manually
⁠Apache based solutions

To spawn a new instance of Moodle:

  • ... using MySQL:

    docker run -d --name DB -e MYSQL_DATABASE=moodle -e MYSQL_RANDOM_ROOT_PASSWORD=yes -e MYSQL_ONETIME_PASSWORD=yes -e MYSQL_USER=^a database user^ -e MYSQL_PASSWORD=^a database password^ mysql:5.7
    docker run -d -P --name moodle --link DB:DB -e MOODLE_DB_HOST=DB -e MOODLE_URL=http://0.0.0.0:8080 -p 8080:80 ellakcy/moodle:mysql_maria_apache_^VERSION^
    

    ** NOTICE ** For now due to the way that mysql authenticates its users, is working with vesrsion 5.7 version of mysql and earlier

  • ... using MariaDB:

    docker run -d --name DB -e MYSQL_DATABASE=^a database name^ -e MYSQL_RANDOM_ROOT_PASSWORD=yes -e MYSQL_ONETIME_PASSWORD=yes -e MYSQL_USER=^a database user^ -e MYSQL_PASSWORD=^a database password^ mariadb:10.2
    docker run -d -P --name moodle --link DB:DB -e MOODLE_DB_HOST=DB -e MOODLE_URL=http://0.0.0.0:8080 -e MOODLE_DB_TYPE="mariadb" -p 8080:80 ellakcy/moodle:mysql_maria_apache_^VERSION^
    

    ** NOTICE ** Please use Mariadb 10.2 and earlier for the same reasons as mysql one.

  • ... using PostgreSQL:

    docker run --name=DB -e POSTGRES_USER=^a database user^ -e POSTGRES_PASSWORD=^a database password^ -e POSTGRES_DB=^a database name^ -d postgres
    docker run -d -P --name moodle --link DB:DB -e MOODLE_DB_HOST=DB -e MOODLE_URL=http://0.0.0.0:8080 -e MOODLE_DB_TYPE="pgsql" -p 8080:80 ellakcy/moodle:postgresql_apache_^VERSION^
    

Then you can visit the following URL in a browser to get started:

http://0.0.0.0:8080

NOTICE: In case you need to keep the data persisted use volumes both in database and moodle containers. NOTICE 2: ^VERSION indicates the moodle version. For the latest lts just use lts or for the latest non lts use latest Notice 3: In case your moodle installation is shipped via

⁠Alpine with Fpm based solutions

For fpm solutions is recomended to use docker-compose. For production use is reccomended the to use the repo https://github.com/ellakcy/moodle-compose⁠ .

⁠Enviromental variables

Also you can use the following extra enviromental variables (using -e option on docker run command):

⁠Enviromental Variables for Default user settings:

A default user is generated during installation. Please provide different credentials during installation.

Variable NameDefault valueDescription
MOODLE_URLhttp://0.0.0.0⁠The URL the site will be served from
MOODLE_ADMINadminThe default administrator's username
MOODLE_ADMIN_PASSWORDAdmin~1234The default administrator's password - *CHANGE IN PRODUCTION
MOODLE_ADMIN_EMAIL[email protected]⁠The default dministrator's email
⁠Enviromental Variables for Database settings:
Variable NameDefault valueDescription
MOODLE_DB_HOSTThe url that the database is accessible
MOODLE_DB_PASSWORDThe password for the database
MOODLE_DB_USERThe username of the database
MOODLE_DB_NAMEThe database name
MOODLE_DB_PORTThe port that the database is accessible
⁠Enviromental Variables for Email settings
Variable NameDefault valueDescription
MOODLE_EMAIL_TYPE_QMAILfalseWhether will use qmail as email (MTA)[https://en.wikipedia.org/wiki/Message_transfer_agent⁠].
MOODLE_EMAIL_HOSTThe host of the smtp server. If not provided then it won't send emails.
⁠Enviromental Variables for reverse proxy
Variable NameDefault valueDescription
MOODLE_REVERSE_LBfalseWhether the moodle rins behind a load balancer or not.
MOODLE_SSLfalseWhether the moodle runs behind an ssl-enabled load balancer.
⁠Volumes

For now you can use the following volumes:

  • /var/moodledata In order to get all the stored data.
  • /var/www/html Containing the moodle source code. This is used by nginx as well.

⁠Using SSL Reverse proxy

⁠Via nginx

In case you want to use the nginx as reverse http proxy is recommended to provide the following settings:

server {
  listen  449 ssl;
  server_name  ^your_domain^;

  ssl_certificate     ^path_to_cert^;
  ssl_certificate_key ^path_to_key^;
  ssl_protocols       TLSv1 TLSv1.1 TLSv1.2;
  ssl_ciphers         HIGH:!aNULL:!MD5;

  location / {
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';

        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_cache_bypass $http_upgrade;

        # In case or running another port please replace the value bellow.
        proxy_pass http://^local_url_and_port^;
  }
}

Where:

  • ^your_domain^: The domain that the moodle is available. Keep in mind that this value is the same in the MOODLE_URL enviromental variable.
  • ^local_url_and_port^: Url that the reverse proxy will forward the requests.
  • ^path_to_cert^,^path_to_key^: The certificate and its key.

As you can see the reverse proxy DOES NOT provide the http Host header according to this⁠ issue.

Also keep in mind to set the following docker enviromental variables MOODLE_REVERSE_LB and MOODLE_SSL into true as well.

⁠Caveats

The following aren't handled, considered, or need work:

  • moodle cronjob (should be called from cron container)
  • log handling (stdout?)
  • email (does it even send?)

Also in case of an error that mentions:

UnixHTTPConnectionPool(host='localhost', port=None): Read timed out. (read timeout=60)

Export the following enviromental variables:

export DOCKER_CLIENT_TIMEOUT=120
export COMPOSE_HTTP_TIMEOUT=120

⁠Credits

This is a fork of jmhardison/docker-moodle⁠.

Tag summary

Content type

Image

Digest

sha256:c8143bf6a…

Size

262.1 MB

Last updated

5 months ago

docker pull ellakcy/moodle:multibase_apache_401_php8