less than 1 minute read

Tags: ,

  • section6-54, 55

Udemy




Writting A Compose File

  • Build a basic compose file for a Drupal content management system website. Docker Hub is your friend
  • Use the drupal image along with the postgres image
  • Use ports to expose Drupal on 8080 so you can localhost:8080
  • Be sure to set POSTGRES_PASSWORD for postgres
  • Walk though Drupal setup via browser
  • Tip: Drupal assumes DB is localhost, but it’s service name
  • Extra Credit: Use volumes to store Drupal unique data

docker-compose.yml

version: '3.1'

services:
  drupal:
    image: drupal
    ports:
      - 8080:80
    volumes: 
      - drupal-modules:/var/www/html/modules
      - drupal-profiles:/var/www/html/profiles
      - drupal-themes:/var/www/html/themes
      # this takes advantage of the feature in Docker that a new anoymous
      # volume (which is what we're creating here) will be initialized with the 
      # existing content of the image at the same location
      - drupal-sites:/var/www/html/sites
  postgres:
    image: postgres:10
    environment:
     POSTGRES_PASSWORD: example
    

volumes:
  drupal-modules:
  drupal-profiles:
  drupal-themes:
  drupal-sites: