Bobcares

Set Up Bitnami Moodle with Docker Compose in 10 Steps

by | Jul 19, 2024

Learn how to set up Bitnami Moodle with Docker Compose in 10 easy steps. Our Moodle Support team is here to help you with your questions and concerns.

How to Set Up Bitnami Moodle with Docker Compose

Are you ready to set up Moodle using Docker? Our Experts are here to help you out. Today, we will walk through getting Docker up and running to configuring and launching Moodle.
How to Set Up Bitnami Moodle with Docker Compose

1. Install Docker

First, check if we have Docker installed on our system. If not, we can download Docker from the official website.

2. Prepare Moodle Repository

Then, download Moodle or make sure we have a Git repository ready. We can use Docker Compose for this task.

3. Create a Docker Compose File

Now, we have to set up a container with the required technology to run and serve the Moodle source code. We’ll need a `docker-compose.yml` file to define the configuration for the containers. So, create this file in the project directory.

services:
mariadb:
image: 'mariadb:10'
container_name: db
environment:
MYSQL_RANDOM_ROOT_PASSWORD: 1
MYSQL_DATABASE: moodle
MYSQL_USER: moodle
MYSQL_PASSWORD: moodlePassword
volumes:
- $HOME/volumes/mysql:/var/lib/mysql
moodle:
image: 'bitnami/moodle:3'
container_name: moodle
environment:
MOODLE_USERNAME: programster
MOODLE_PASSWORD: thisIsMyMoodleLoginPassword
MOODLE_EMAIL: admin@programster.org
MARIADB_HOST: db
MARIADB_PORT_NUMBER: 3306
MOODLE_DATABASE_USER: moodle
MOODLE_DATABASE_NAME: moodle
MOODLE_DATABASE_PASSWORD: moodlePassword
ALLOW_EMPTY_PASSWORD: "no"
ports:
- '80:80'
- '443:443'
volumes:
- $HOME/volumes/moodle:/bitnami'
depends_on:
- mariadb
volumes:
mariadb_data:
driver: local
moodle_data:
driver: local

4. Download Docker Images

Next, download the needed Docker images. Then, open a terminal and run these commands:

docker pull mariadb:10
docker pull bitnami/moodle:3

5. Configure the Database Service

Then, define a service for MariaDB in the `docker-compose.yml` file. Here’s the configuration:


services:
mariadb:
image: "bitnami/mariadb:10.1"
networks:
- moodle-net
environment:
- MARIADB_USER=bn_moodle
- MARIADB_DATABASE=bitnami_moodle
- ALLOW_EMPTY_PASSWORD=yes
volumes:
- type: bind
source: /home/maria_data
target: /bitnami
ports:
- "3306:3306"

We have to make sure Docker can read/write the `/home/maria_data` folder on the host:

sudo chmod a+rwx /home/maria_data/

6. Configure the Moodle Service

Now, we will use a pre-built image for PHP and Apache:

docker pull webdevops/php-apache:7.3
docker run -d -p 80:80 efec3d223189

Then, go to `localhost` or the public IP address to see an empty Apache2 page. This confirms that the PHP & Apache image is running correctly.

7. Define the Docker Network and Volumes

Then, add these lines to the `docker-compose.yml` file:

networks:
moodle-net:
driver: bridge
volumes:
mariadb_data:
driver: local
moodle_data:
driver: local

8. Start the Containers

Now, it is time to start our containers with this command:

docker-compose up -d

9. Complete Moodle Installation

Then, go to `localhost` or our public IP address to start the Moodle installation process. We have to enter the database details specified in the MariaDB service configuration.

10. Verify Persistent Storage

After setting up Moodle, the host volumes/folders will be populated with data from the containers:

ls $HOME/volumes/moodle/

# Output: cache filedir lang localcache lock moodle muc sessions temp trashdir

ls /home/maria_data/mariadb/data/

# Output: aria_log.00000001 aria_log_control bitnami_moodle ibdata1 ib_logfile0 ib_logfile1 multi-master.info mysql mysql_upgrade_info performance_schema tc.log test

After the above steps, we have successfully set up Moodle using Docker. Now we can enjoy a fully functional Moodle instance backed by Docker containers.

[Need assistance with a different issue? Our team is available 24/7.]

Conclusion

In brief, our Support Experts demonstrated how to set up Bitnami Moodle with Docker Compose in 10 easy steps.

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Never again lose customers to poor
server speed! Let us help you.