title: How to set up a Drupal website with an accessible codebase in Docker?
body: <p>I'm trying to set up a new local Drupal 7 website with Docker, using Docker Compose. I would like the <em>sites/all</em> and <em>sites/default/files</em> folders to be accessible via my file explorer, such that I can for example edit the files inside them in an editor and easily create custom modules.</p>
  
  <p><strong>Document structure</strong></p>
  
  <pre><code>test-website
    --db-backups
    --sites
    --docker-compose.yml
  </code></pre>
  
  <p><strong>docker-compose.yml file</strong></p>
  
  <pre><code>version: '3.1'
  services:
    drupal:
      image: drupal:7
      ports:
        - 8080:80
      volumes:
        - ./sites:/var/www/html/sites
      restart: always
  
    db:
      image: mysql:5.7
      volumes:
        - ./db-backups:/var/mysql/backups
      environment:
        MYSQL_ROOT_PASSWORD: root
        MYSQL_DATABASE: test
        MYSQL_USER: user
        MYSQL_PASSWORD: password
      ports:
        - 3030:3030
  
    pma:
      image: phpmyadmin/phpmyadmin
      environment:
        PMA_HOST: db
        PMA_USER: user
        PMA_PASSWORD: password
        PHP_UPLOAD_MAX_FILESIZE: 1G
        PHP_MAX_INPUT_VARS: 1G
      ports:
       - 9090:9090
  
  volumes:
    sites:
    db-backups:
  </code></pre>
  
  <p>Composing the <em>docker-compose.yml</em> file in the command line allows me to navigate to localhost:8080 as desired, but I get an error during the requirements verification step of the installation:</p>
  
  <blockquote>
    <p>The directory sites/default/files does not exist. An automated attempt to create this directory failed, possibly due to a permissions problem. To proceed with the installation, either create the directory and modify its permissions manually or ensure that the installer has the permissions to create it automatically. For more information, see INSTALL.txt or the online handbook.</p>
  </blockquote>
  
  <p>Something seems to be wrong with my volume, but I don't know what and I can't find clear documentation online. Also, I now tried to put <em>sites</em> as a whole in a volume, but that leads to data loss when the Docker containers are killed and restarted (see <a href="https://github.com/docker-library/drupal/issues/3" rel="nofollow noreferrer">https://github.com/docker-library/drupal/issues/3</a>). Thus, I need a solution that persists my data.</p>
  
  <p>Which steps should I follow to set up my Drupal 7 website correctly?</p>