Dockerized Drupal 9 with persistent database

By ReginaHack, 18 July, 2020

Dockerized Drupal 9Until today I used to run the admin setup of my blog on my local using lando. Which was fine and is great for local dev, however I also wanted to be able to blog using my tablet or phone while not having my MacBook in front of me. In addition I do like having backups.

I've now set it up on my computer in my office which is running at all times anyhow, accessible from anywhere and backed up to my Synology. The setup is using Docker with a persistent database and volume for the modules/sites etc folders.

Here is the docker-compose.yml (default passwords as per bitnami image are shown):


version: '2'
services:
  mariadb:
    image: 'docker.io/bitnami/mariadb:10.3-debian-10'
    environment:
      - ALLOW_EMPTY_PASSWORD=yes
      - MARIADB_USER=bn_drupal
      - MARIADB_DATABASE=bitnami_drupal
    volumes:
      - './database/mariadb-persistence:/bitnami/mariadb'
  drupal:
    image: 'docker.io/bitnami/drupal:9-debian-10'
    ports:
      - '80:8080'
      - '443:8443'
    environment:
      - DRUPAL_DATABASE_HOST=mariadb
      - DRUPAL_DATABASE_PORT_NUMBER=3306
      - DRUPAL_DATABASE_USER=bn_drupal
      - DRUPAL_DATABASE_NAME=bitnami_drupal
      - ALLOW_EMPTY_PASSWORD=yes
    volumes:
      - './drupal/drupal-persistence:/bitnami/drupal'
    depends_on:
      - maria

Source: https://hub.docker.com/r/bitnami/drupal

Just run:

docker-compose up

and localhost should show your Drupal 9 installation.