Create a directory named example37 and the example37/docker-compose.yml file.
We will create drupal and postgres services. The drupal container is created with four mounted
named volumes for four different drupal's directories: modules, profiles, sites and themes.
The postgres containers is created with postgres admin password of 1234.
It will mount a named volume for the postgres's data directory.
version: '3'
services:
drupal:
image: drupal
ports:
- "8080:80"
volumes:
- drupal-modules:/var/www/html/modules
- drupal-profiles:/var/www/html/profiles
- drupal-sites:/var/www/html/sites
- drupal-themes:/var/www/html/themes
postgres:
image: postgres:10-alpine
environment:
- POSTGRES_PASSWORD=
volumes:
- postgres-data:/var/lib/postgresql/data
volumes:
drupal-modules:
drupal-profiles:
drupal-sites:
drupal-themes:
postgres-data:
In order for all the named volumes to work, we need to add volumes: section at the bottom of the YAML file.
And we have to specify all the named volume under this section.
Make sure that you check out the default parameter values from docker hub page, i.e., DB username, DB name, ...
https://hub.docker.com/_/postgres/
In the example37 directory, run the command below
$ docker-compose up Creating network "example37_default" with the default driver Creating volume "example37-modules" with default driver Creating volume "example37_drupal-profiles" with default driver Creating volume "example37_drupal-sites" with default driver Creating volume "example37-themes" with default driver Creating volume "example37_postgres-data" with default driver Creating example37_postgres_1 ... done Creating example37_drupal_1 ... done Attaching to example37_postgres_1, example37_drupal_1 postgres_1 | The files belonging to this database system will be owned by user "postgres". postgres_1 | This user must also own the server process. postgres_1 | postgres_1 | The database cluster will be initialized with locale "en_US.utf8". postgres_1 | The default database encoding has accordingly been set to "UTF8". postgres_1 | The default text search configuration will be set to "english". postgres_1 | postgres_1 | Data page checksums are disabled. postgres_1 | postgres_1 | fixing permissions on existing directory /var/lib/postgresql/data ... ok ... ... drupal_1 | AH00558: apache2: Could not reliably determine the server's fully qualified domain name, ... drupal_1 | [Tue Aug 28 19:54:48.772012 2018] [mpm_prefork:notice] [pid 1] AH00163: Apache/2.4.25 (Debian) ... drupal_1 | [Tue Aug 28 19:54:48.778702 2018] [core:notice] [pid 1] AH00094: Command line: 'apache2 -D FOREGROUND' ... ... postgres_1 | 2018-08-28 19:54:50.941 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432 postgres_1 | 2018-08-28 19:54:50.943 UTC [1] LOG: listening on IPv6 address "::", port 5432 postgres_1 | 2018-08-28 19:54:50.958 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432" postgres_1 | 2018-08-28 19:54:51.000 UTC [40] LOG: database system was shut down at 2018-08-28 19:54:50 UTC postgres_1 | 2018-08-28 19:54:51.009 UTC [1] LOG: database system is ready to accept connections
Now, we can access Drupal installation page.
http://localhost:8080/core/install.php
Choose English language, Standard Intallation type.
For database configuration, choose PostgreSQL then specify parameters as shown below:
- Database name: postgres
- Database username: postgres
- Database password:
- Host (Advanced options): postgres
If everything is configured correctly, the installation process will start.
This process could take a couple of minutes. After the installation,
it brings us to the Configure site section. Once we finish configure the site.
We can access the Drupal from the URL http://localhost:8080/