Docker images for Moodle development

Re: Docker images for Moodle development

by Avi Levy -
Number of replies: 0
Picture of Core developers Picture of Plugin developers Picture of Testers

Hi Dan,

In The last few month all ouer Dev env moved to containers, We are work with docker and docker-compose to run different env for moodle. The solution we implimented to solve the problem of container user and OS user is to change the UID of the PHP docker to the UID of the developer user. then the www-data user have the same UID as the developer so the developer and php-fpm have the full access to the files. 

You can find the php container by pull sysbind/php deocker


here is example of yaml of docker compose:

version: '2'


services:

  db:

    image: mariadb:10.0.26

    volumes: 

      - /your/workspaces/mysql/10.0.26:/var/lib/mysql

      - ./mariadb.cnf:/etc/mysql/conf.d/mariadb.cnf

    restart: always

    environment:

      MYSQL_ROOT_PASSWORD: moodleroot

      MYSQL_USER: moodleuser

      MYSQL_PASSWORD: realpassword

      MYSQL_DATABASE: moodle

    security_opt:

      - label:disable

    # DB ports need only if you want to debug DB from your host
    ports:

      - "3306:3306"

  webserver:

    image: nginx:1.10.1

    volumes:

      - ../nginx.conf:/etc/nginx/nginx.conf

      - ../virtualhost.conf:/etc/nginx/conf.d/virtualhost.conf

      - /your/workspaces/PHP:/var/www/html

      - /your/workspaces/moodledata:/var/www/moodledata

      - ../../ssl:/etc/nginx/ssl

    links:

      - db

      - php

    ports:

      - "80:80"

      - "443:443"

    security_opt:

      - label:disable

  php:

    image: sysbind/php:7.0-fpm

    volumes:

      - /your/workspaces/PHP:/var/www/html

      - /your/workspaces/moodledata:/var/www/moodledata

      - ../../php.ini:/usr/local/etc/php/php.ini

    security_opt:

      - label:disable

    links:

      - db

      - memcached

      - redis

    environment:

      # You can find it by echo $UID

      - UID=XXXX

  memcached:

    image: memcached

  redis:

    image: redis