Moodle is an open-source learning management system (LMS), probably the most popular and widely used of all those available.
Before getting started, we recommend trying the service at https://moodle.org/demo, to see whether it suits your particular requirements or meets the reader's goals.
In this article, we show you how to install Moodle using Docker containers, along with its basic configuration for courses, users, and permissions, so basic knowledge of Docker and docker-compose is recommended.
Creating the VPS
As mentioned, we will use the Docker image with Ubuntu 24.04 LTS. To decide how many resources to allocate to the VPS, you need to know the server's workload, that is, how many users you expect to have connected at the same time and what activities they will be performing. Simply browsing resources (documents, images, ...) is not the same as supporting exams with quizzes or assignments, which requires significantly higher performance.
The same applies to storage: it depends on the files we want to store. For a basic installation, at least 10GB of SSD storage is recommended (for a few users).
Once it has been created with the desired resource configuration, we will install docker-compose with the command
apt install docker-compose-pluginYou also need to open the following ports:
- 80/TCP (optional): the connection will initially use HTTPS, but this can be opened for development and testing purposes
- 443/TCP: to provide the service over HTTPS
Installation
We will use the following Docker images:
- MariaDB
- Moodle
For both images, we will use those created by Bitnami, as they greatly simplify configuration.
Configuring Let's Encrypt
First of all, to use a valid SSL certificate and prevent users from seeing a warning that the site is not secure when accessing our system, we will obtain one through Let's Encrypt. To do this, we will use a tool created by Bitnami that simplifies the process (since we also have the Bitnami container).
Run the following commands on our VPS:
cd /tmp
curl -Ls https://api.github.com/repos/go-acme/lego/releases/latest | grep browser_download_url
| grep linux_amd64 | cut -d '"' -f 4 | wget -i -
tar xf lego_vX.Y.Z_linux_amd64.tar.gz
mkdir -p /opt/bitnami/letsencrypt
mv lego /opt/bitnami/letsencrypt/lego
Replace X.Y.Z with the version downloaded.
To create the certificates, simply run: /opt/bitnami/letsencrypt/lego --tls --email="EMAIL" --domains="DOMINIO" --path="/opt/bitnami/letsencrypt" run.
When it finishes, the certificates (public and private key) will be saved in /opt/bitnami/letsencrypt/certificates/ (.crt and .key files, respectively).
Docker-compose
We will use the following docker-compose configuration file:
services:
mariadb:
image: docker.io/bitnami/mariadb:11.4
restart: unless-stopped
environment:
- MARIADB_USER=bn_moodle
- MARIADB_DATABASE=bitnami_moodle
- MARIADB_PASSWORD=${DB_PASSWORD}
- MARIADB_ROOT_PASSWORD=${DB_ROOT_PASSWORD}
- MARIADB_CHARACTER_SET=utf8mb4
- MARIADB_COLLATE=utf8mb4_unicode_ci
volumes:
- /root/moodle/mariadb-data:/bitnami/mariadb
moodle:
image: docker.io/bitnami/moodle:5.2
restart: unless-stopped
depends_on:
- mariadb
environment:
- MOODLE_DATABASE_HOST=mariadb
- MOODLE_DATABASE_PORT_NUMBER=3306
- MOODLE_DATABASE_USER=bn_moodle
- MOODLE_DATABASE_NAME=bitnami_moodle
- MOODLE_DATABASE_PASSWORD=${DB_PASSWORD}
- MOODLE_USERNAME=admin
- MOODLE_PASSWORD=${MOODLE_ADMIN_PASSWORD}
- MOODLE_EMAIL=hola@mundo.es
ports:
- "80:8080"
- "443:8443"
volumes:
- /root/moodle/data:/bitnami/moodle
- /root/moodle/moodledata:/bitnami/moodledata
- /opt/bitnami/letsencrypt/certificates/DOMINIO.crt:/opt/bitnami/apache/conf/bitnami/certs/server.crt:ro
- /opt/bitnami/letsencrypt/certificates/DOMINIO.key:/opt/bitnami/apache/conf/bitnami/certs/server.key:roIn addition to the comments in the YAML itself, the following two volumes will be used to save data so it is not lost if the containers stop (you need to create them):
- MariaDB: database-related data will be stored in /root/moodle/mariadb-data
- Moodle: Moodle data will be stored in /root/moodle/data
Note
You need to grant permissions to the two folders created so the docker user can write to them, so run the following for each one: chown -R 1001:1001 CARPETA
Once the directories have been created and the certificate volumes changed, run docker-compose up -d.
If everything went well, we can access our server's URL over HTTPS and will see the following screen:
Configuring Moodle
To access the moodle administration panel, you need to log in with the credentials written in the file docker-compose.yml, in our case admin and moodle:
First, we strongly recommend registering our site to receive security alerts and allow users of our platform to use the Moodle mobile app to access the service (red box).
We will briefly review Moodle's basic features, along with creating users and courses.
Changing the language
We may well want to offer our platform in a language other than English, so we will need to install the language pack and enable it by default.
In Site administration, go to Language > Language packs and select the desired language:
After installing it, go to Language > Language settings and set it as the default:
Changing site details
We will also need to change the site's name and description, which we access under Página principal > Ajustes de la página principal:
This also allows us to change the blocks displayed when accessing our site. In the Apariencia section of the administration menu, we can change various settings such as the icon, colors, or theme used:
Adding courses
Courses are the different units in which students and teachers can be enrolled. An example of a course could be the Mathematics class in 1º de ESO.
Before creating the course, we recommend creating a category for it. In the previous example, the category would encompass all courses at one level: the category would be 1ºESO and each course would be a subject at that level: Mathematics, Spanish Language and Literature, Natural Sciences,...
Therefore, we create a category:
Once it has been created, we will add a new course:
Adding users
Users will be the different clients of our Moodle system, divided into 2 roles: Alumno and Profesor.
You can add several access methods, such as an LDAP server. In this example, to keep things simple, we will enter users one by one. To add a new user:
From this point on, the user created can access the system with their credentials, but will not be able to see any courses because they are not enrolled in any (and by default users cannot enroll themselves).
Therefore, we will enroll this user as a Mathematics teacher for 1º ESO. To do this, go to the course in question and select Participantes in the left menu. In the view that appears, there is a button in the upper right for enrolling users:
Select our user and assign the role of Profesor.
Note
To add students, the process is the same, simply changing the role to Alumno.
Now, if we log in as the teacher, we will see the Mathematics course in the Área personal, which we can access and edit (as the teacher, using the gear in the upper right):
Extensions
You can add more functionality to the Moodle system through plug-ins.
For example, you can allow users to create Jitsi video conferences, which requires a VPS or Docker with Jitsi.
Documentation
Extensive documentation for customizing and adapting Moodle to our needs is available in its Documentation.
In addition, with Bitnami's Moodle image, you can easily configure certain services, such as an SMTP server to send emails about Moodle activities.
This article was written by David Población, a regular Clouding contributor.