docker-compose.yml drupal connecting to a mysql instance

Submitted by barnettech on Fri, 01/10/2020 - 12:50
./root/drupal8/docker-compose.yml
# Drupal with MySQL
#
# Access via "http://localhost:8080"
#   (or "http://$(docker-machine ip):8080" if using docker-machine)
#
# During initial Drupal setup,
# Database type: PostgreSQL
# Database name: postgres
# Database username: postgres
# Database password: example
# ADVANCED OPTIONS; Database host: postgres

version: '3.3'

services:

  drupal:
    image: drupal:8-apache
    ports:
      - 8081:80
    volumes:
      - /opt/drupal8/modules:/var/www/html/modules
      - /opt/drupal8/profiles:/var/www/html/profiles
      - /opt/drupal8/themes:/var/www/html/themes
      # this takes advantage of the feature in Docker that a new anonymous
      # volume (which is what we're creating here) will be initialized with the
      # existing content of the image at the same location
      - /opt/drupal8/sites:/var/www/html/sites
    restart: always
    networks:
      - backend
      - wordpress_backend

  #postgres:
  #  image: postgres:10
  #  environment:
  #    POSTGRES_PASSWORD: onelink
  #  restart: always

networks:
    backend:
    wordpress_backend:
      external: true

also a good command

  docker network ls