Docker4Drupal - Mount with existing Drupal¶
This is meant for existing Drupal projects made with drupal-composer/drupal-project.
- Download/unpack
docker4drupal
source code from the latest release - Copy
docker4drupal
to site folder withcp -a docker4drupal/. your-drupal-folder/
- Enter
your-drupal-project-folder
and deletedocker-compose.override.yml
as 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/web
for composer-based projects where Drupal is inweb
subdirectory - If you want to import your database, uncomment the line for
mariadb-init
bind mount in yourdocker-compose.yml
file. Create the directory./mariadb-init
in the same directory (mkdir mariadb-init
) and put there your.sql .sql.gz .sh
file(s). All SQL files will be automatically imported once MariaDB container has started. -
Ensure database access settings in your
settings.php
corresponds to values in.env
file, 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 -d
to start containers. - If needed, run composer install with
docker-compose exec php composer install
- That's it! Proceed with
Drupal
installation 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
.