Docker4Drupal - Mount with existing Drupal¶
This is meant for existing Drupal projects made with drupal-composer/drupal-project.
- Download/unpack
docker4drupalsource code from the latest release - Copy
docker4drupalto site folder withcp -a docker4drupal/. your-drupal-folder/ - Enter
your-drupal-project-folderand deletedocker-compose.override.ymlas it's used to deploy vanilla Drupal - Ensure
NGINX_SERVER_ROOT(orAPACHE_DOCUMENT_ROOT) is correct on yourdocker-compose.yml, by default set to/var/www/html/webfor composer-based projects where Drupal is inwebsubdirectory - If you want to import your database, uncomment the line for
mariadb-initbind mount in yourdocker-compose.ymlfile. Create the directory./mariadb-initin the same directory (mkdir mariadb-init) and put there your.sql .sql.gz .shfile(s). All SQL files will be automatically imported once MariaDB container has started. -
Ensure database access settings in your
settings.phpcorresponds to values in.envfile, e.g.:$databases['default']['default'] = array ( 'database' => 'drupal', // same as $DB_NAME 'username' => 'drupal', // same as $DB_USER 'password' => 'drupal', // same as $DB_PASSWORD 'host' => 'mariadb', // same as $DB_HOST 'driver' => 'mysql', // same as $DB_DRIVER 'port' => '3306', // different for PostgreSQL 'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql', // different for PostgreSQL 'prefix' => '', );
-
Run
docker-compose up -dto start containers. - If needed, run composer install with
docker-compose exec php composer install - That's it! Proceed with
Drupalinstallation at http://drupal.docker.localhost:8000 - If you have trouble to access it, try to configure domains
- You can see status of your containers and their logs via portainer: http://portainer.drupal.docker.localhost:8000
Default database user, password and database name are all drupal, database host is mariadb.