title: How to dockerize drupal 8 multi-site on local development?
body: <p>I'm trying to containerize my existing drupal 8 multi-site using docker. I'm basing my docker-compose file on <a href="https://github.com/wodby/docker4drupal" rel="nofollow noreferrer">docker4drupal</a>. I'm also following docker4drupal <a href="https://github.com/wodby/docker4drupal/issues/299" rel="nofollow noreferrer">More Multisite Questions #299</a> but still unable to resolve my drupal 8 multi-site using only one database on my Mac OS local development. I'm following this Drupalize.me <a href="https://drupalize.me/tutorial/dockerize-existing-project?p=3040" rel="nofollow noreferrer">Dockerize an Existing Project</a> to containerize my existing drupal 8 multi-site and using Wodby's <a href="https://docs.wodby.com/stacks/drupal/#deploy-all-sites-in-one-instance" rel="nofollow noreferrer">Deploy all sites in one instance</a> documentation on setting up my current multi-site.</p>
  
  <p>I'm able to access portainer.localhost, whoami.docker.localhost, pma.localhost, mailhog.localhost, and traefik (localhost:8080/dashboard/). What I cannot access are: reverse-proxy.drupalsites.localhost, php.drupalsites.localhost, mariadb.drupalsites.localhost, and localhost. The error that shows on the page when I access is "404 page not found". The error for accessing localhost is "File not found."</p>
  
  <p>Here's my docker-compose.yml file.</p>
  
  <pre><code>version: "3"
  
  services:
    mariadb:
      image: wodby/mariadb:$MARIADB_TAG
      container_name: "${PROJECT_NAME}_mariadb"
      stop_grace_period: 30s
      environment:
        MYSQL_ROOT_PASSWORD: $DB_ROOT_PASSWORD
        MYSQL_DATABASE: $DB_NAME
        MYSQL_USER: $DB_USER
        MYSQL_PASSWORD: $DB_PASSWORD
      volumes:
        - ./db-backups:/var/lib/backups:delegated
      ports:
        - "3306:3306"
    php:
      image: wodby/drupal-php:$PHP_TAG
      container_name: "${PROJECT_NAME}_php"
      environment:
        PHP_SENDMAIL_PATH: /usr/sbin/sendmail -t -i -S mailhog:1025
        DB_HOST: $DB_HOST
        DB_USER: $DB_USER
        DB_PASSWORD: $DB_PASSWORD
        DB_NAME: $DB_NAME
        DB_DRIVER: $DB_DRIVER
      volumes:
        - ./docroot:/var/www/html:cached
  
    nginx:
      image: wodby/drupal-nginx:$NGINX_TAG
      container_name: "${PROJECT_NAME}_nginx"
      depends_on:
        - php
      environment:
  #      NGINX_PAGESPEED: "on"
        NGINX_STATIC_CONTENT_OPEN_FILE_CACHE: "off"
        NGINX_ERROR_LOG_LEVEL: debug
        NGINX_BACKEND_HOST: php
        NGINX_SERVER_ROOT: /var/www/html/web
      volumes:
        - ./docroot:/var/www/html
      labels:
        - 'traefik.backend=nginx'
        - 'traefik.port=80'
        - 'traefik.frontend.rule=Host:${PROJECT_BASE_URL}'
  
    mailhog:
      image: mailhog/mailhog
      container_name: "${PROJECT_NAME}_mailhog"
      labels:
        - 'traefik.backend=mailhog'
        - 'traefik.port=8025'
        - 'traefik.frontend.rule=Host:mailhog.${PROJECT_BASE_URL}'
  
    pma:
      image: phpmyadmin/phpmyadmin
      container_name: "${PROJECT_NAME}_pma"
      environment:
        PMA_HOST: $DB_HOST
        PMA_USER: $PMA_USER
        PMA_PASSWORD: $DB_PASSWORD
        PHP_UPLOAD_MAX_FILESIZE: 1G
        PHP_MAX_INPUT_VARS: 1G
      labels:
        - 'traefik.backend=pma'
        - 'traefik.port=80'
        - 'traefik.frontend.rule=Host:pma.${PROJECT_BASE_URL}'
      ports:
        - "8001:80"
  
    portainer:
      image: portainer/portainer
      container_name: "${PROJECT_NAME}_portainer"
      command: --no-auth -H unix:///var/run/docker.sock
      volumes:
        - /var/run/docker.sock:/var/run/docker.sock
      labels:
        - 'traefik.backend=portainer'
        - 'traefik.port=9000'
        - 'traefik.frontend.rule=Host:portainer.${PROJECT_BASE_URL}'
  
    reverse-proxy:
      image: traefik #The official Traefik docker image
      container_name: "${PROJECT_NAME}_traefik"
      command: --api --docker #Enables the web UI and tells Træfik to listen to docker
      ports:
        - "80:80" #The HTTP port
        - "8080:8080" #The Web UI (enabled by --api)
      volumes:
        - /var/run/docker.sock:/var/run/docker.sock # So that Traefik can listen to the Docker events
  
    whoami:
        image: emilevauge/whoami # A container that exposes an API to show its IP address
        labels:
          - "traefik.frontend.rule=Host:whoami.docker.localhost"
  </code></pre>
  
  <p>And this is my environment variables.</p>
  
  <pre><code>#Set environment default values for each site in multi-site
  
  ###PROJECT SETTINGS
  PROJECT_NAME=docker-project
  PROJECT_BASE_URL=localhost
  
  DB_ROOT_PASSWORD=123456
  DB_NAME=example
  DB_USER=admin
  DB_PASSWORD=654321
  DB_HOST=mariadb
  DB_DRIVER=mysql
  PMA_USER=admin
  
  ### --- MARIADB ---
  MARIADB_TAG=10.3
  
  ### --- Drupal 8 ---
  DRUPAL_TAG=8-7.2-4.6.0
  
  ### --- PHP ---
  PHP_TAG=7.2
  
  ### -- NGINX ---
  NGINX_TAG=1.15
  </code></pre>