LMSouq
moodle-core Open

Dockerize moodle instance

RA
rafaelp014
1 month ago
3 views
Problem Description
Im trying to dockerize the moodle i've installed locally so it is easier for me to manage it when i elevate the moodle to "another level". In the future i will have several moodles so i need containers to be easier to manage them. I've tried several aproches. I tried do create my onw image , using a dockerfile: ``` # Use an official PHP runtime as a parent image FROM php:7.4-apache # Set the working directory to /var/www/html WORKDIR /var/www/html # Copy the contents of your Moodle directory to the container COPY . /var/www/html # Install any additional dependencies or PHP extensions if needed # For example: # RUN docker-php-ext-install pdo_mysql # Expose port 80 to the outside world EXPOSE 80 # Start Apache when the container launches CMD ["apache2-foreground"] ``` and a docker-compose.yml: ``` version: '3.8' services: moodle: image: your-moodle-image-name ports: - "8080:80" # Adjust the port mapping as needed ``` but nothing works. Also , i've tried to make just an docker-compose.yml file that runs both moodle and mariadb (but with bitnami/moodle image): ``` version: '2' services: mariadb: image: mariadb container_name: mariadb2 ports: - 3306:3306 volumes: - /srv/dev-disk-by-x/dckcnfg/moodle:/var/lib/mysql environment: - MYSQL_ROOT_PASSWORD=passroot - MYSQL_ROOT_USER=root - MYSQL_DATABASE=moodle - ALLOW_EMPTY_PASSWORD=yes moodle: image: bitnami/moodle container_name: moodle2 ports: - 8089:80 # - 8449:443 environment: - MOODLE_DATABASE_HOST=localhost - MOODLE_DATABASE_USER=user - MOODLE_DATABASE_PASSWORD=pass - MOODLE_DATABASE_NAME=moodle - ALLOW_EMPTY_PASSWORD=yes volumes: - /var/www/html/moodle:/opt/bitnami/moodle - /var/www/moodledata:/opt/bitnami/moodledata depends_on: - mariadb links: - mariadb:mariadb ``` and it does not work. I get "trying to connect to db server" on the moodle logs. I guess it is beacause for me to deploy mariadb containar , i cannot have mariadb running for moodle outside the container , and then , i never get the container to speak with it to the outside.

AI-Generated Solution

Powered by LMSouq AI · GPT-4.1-mini

✓ Solution Ready
Analyzing problem and generating solution…
Was this solution helpful?
Back to Knowledge Base