This article discusses and demonstrates the design and implementation of Moodle using Docker with the option for later deployments with Kubernetes. We’re using Ubuntu 24.04 but this should work fine on similar versions of Ubuntu as well.
The key points are:
- Moodle is deployed via a Docker container.
- Moodle references an external MariaDB server.
- Moodle data is shared across containers.
The diagram below illustrates the above.
With the above scheme, a future deployment using Kubernetes is possible. For this article, we’re going to keep it one step simpler by using local storage on the underling Ubuntu server, and the MariaDB server is also hosted on the underling Ubuntu server.
Install the required software:
apt install mariadb-server docker docker.io docker-compose
mariadb-server = 1:10.11.8-0ubuntu0.24.04.1
vi /etc/mysql/mariadb.conf.d/50-server.cnf bind-address = 0.0.0.0
systemctl enable mariadb systemctl restart mariadb
Create the new database, create a new user and set a password:
CREATE DATABASE moodle; CREATE USER 'moodleuser'@'%'; GRANT ALL PRIVILEGES ON moodle.* TO 'moodleuser'@'%'; SET PASSWORD FOR 'moodleuser'@'%' = PASSWORD('sfd34yu3g4geh'); FLUSH PRIVILEGES;
Create a few directories on the Moodle docker server:
mkdir -p /root/moodle-docker/moodle mkdir -p /root/moodle-docker/moodledata
Create the “docker-compose.yml” file and populate it:
/root/moodle-docker/docker-compose.yml
Add the following content:
services: moodle: image: docker.io/bitnami/moodle:4.5 ports: - '80:8080' - '443:8443' environment: - MOODLE_DATABASE_HOST=10.1.2.3 - MOODLE_DATABASE_PORT_NUMBER=3306 - MOODLE_DATABASE_USER=moodleuser - MOODLE_DATABASE_NAME=moodle - MOODLE_DATABASE_PASSWORD=sfd34yu3g4geh - ALLOW_EMPTY_PASSWORD=no - MOODLE_USERNAME=admin - MOODLE_PASSWORD=MyPass1 - BITNAMI_DEBUG=true volumes: - 'moodle_data:/root/moodle-docker/moodle' - 'moodledata_data:/root/moodle-docker/moodledata' volumes: moodle_data: driver: local moodledata_data: driver: local
Start the docker container:
cd /root/moodle-docker/ docker-compose up -d
- https://<ip-address>/
- http://<ip-address>/
- Username: admin
- Password: MyPass1