Moodle is a learning management platform that designed for educators and learners. Moodle is an open-source project available under the GPLv3+ license.
This tutorial explains how to install Moodle inside a Docker container in the Linux. Commands have been tested on Ubuntu.
Make sure you have installed Docker in your system. If you are using Ubuntu, installation instructions can be found in the post.
You also need to have a running MySQL container. Instructions can be found in the post.
Before starting, create
docker exec -it mysql mysql -u root -p -e "CREATE DATABASE moodle"
- Host network
Run the following command to create a container for Moodle that uses host network:
docker run -d --name=moodle --restart=always --network=host \ -v /opt/moodle/data:/bitnami \ -e MOODLE_USERNAME=admin \ -e MOODLE_PASSWORD=pwd123 \ -e MOODLE_DATABASE_TYPE=mysqli \ -e MOODLE_DATABASE_USER=root \ -e MOODLE_DATABASE_PASSWORD=pwd123 \ -e MOODLE_DATABASE_NAME=moodle \ -e MOODLE_DATABASE_HOST=127.0.0.1 \ bitnami/moodle
MySQL container should run on host network as well.
- User-defined bridge network
User-defined bridge network can be used for listening on different port. By default, Moodle service is listening on port 8080. It can be changed with
docker network create app-net
docker run -d --name=moodle --restart=always --network=app-net \ -p 8081:8080 \ -v /opt/moodle/data:/bitnami \ -e MOODLE_USERNAME=admin \ -e MOODLE_PASSWORD=pwd123 \ -e MOODLE_DATABASE_TYPE=mysqli \ -e MOODLE_DATABASE_USER=root \ -e MOODLE_DATABASE_PASSWORD=pwd123 \ -e MOODLE_DATABASE_NAME=moodle \ -e MOODLE_DATABASE_HOST=mysql \ bitnami/moodle
MySQL container should run on the same user-defined bridge network as well.
- It might take a while before initialization is finished and the Docker container starts to respond to requests.
- Don't forget to change admin password for Moodle using
MOODLE_DATABASE_PASSWORDcan be used to specify MySQL credentials.
- When user-defined bridge network is used, don't forget to change
MOODLE_DATABASE_HOST. It specifies MySQL container name.
Open a web browser and go to
<IP_ADDRESS> is the IP address of the system. Log in to the dashboard with the
admin username and password.
To completely remove Moodle, remove its container:
docker rm --force moodle
Remove Moodle image:
docker rmi bitnami/moodle
You can also remove Moodle data:
sudo rm -rf /opt/moodle
If a user-defined bridge network was created, you can delete it as follows:
docker network rm app-net
Leave a CommentCancel reply