Three steps to install Drupal 8 operating environment with Docker

3.steps to install Drupal 8 operating environment with Docker

This article introduces the implementation method of installing Drupal8 runtime environment with Docker

Supporting video

## About Docker

Docker is an open source application container engine that allows developers to package their applications and dependencies into a portable image, and then publish it to any popular Linux or Windows machine, which can also be virtualized. Containers use the sandbox mechanism completely, and there will be no interfaces between them.

Baidu Encyclopedia About Docker

2. About Drupal

Drupal is an open source content management framework (CMF) written in PHP language, which is composed of a content management system (CMS) and a PHP development framework (Framework). It has won the world's best CMS award for many years, and it is the most famous web application based on the PHP language. As of the end of 2011, a total of 13,802 web experts have participated in the development of Drupal; 729,791 web designers in 228 countries using 181 languages use Drupal. Famous cases include: the United Nations, the White House, the US Department of Commerce, the New York Times, Warner, Disney, FedEx, Sony, Harvard University, Ubuntu, etc.

Baidu Encyclopedia About Drupal

3. About the Drupal operating environment

Apache (Recommended)

You can use Apache's mod_rewrite to extend Drupal's clean url. In Drupal 8, clean urls is enabled by default and cannot be turned off. So in order for Drupal to work properly, mod_rewrite needs to be installed and enabled.

The virtual host must be configured to include AllowOverride All to allow drupal's .htaccess file to work.

Database

MySQL 5.5.3/MariaDB 5.5.20/Percona Server 5.5.8 or higher with PDO and an InnoDB-compatible primary storage engine,

PostgreSQL 9.1.2 or higher with PDO,

SQLite 3.6.8 or higher

PHP

Drupal 8: PHP 5.5.9 or higher

Get it in three steps

Seeing the configuration environment, many beginners will be discouraged. It is thanks to Docker's mirroring and container technology that can save us the trouble of configuring the environment. Moreover, this environment can be exactly the same as the online environment, saving us the trouble of deployment and maintenance.

It takes only three steps to install the Drupal 8 runtime environment with Docker. Two containers need to be installed, provided that we have installed Docker.

The first step is to install the database

Enter the following command on the command line:

docker run/
-e MYSQL_ROOT_PASSWORD=admin/
-e MYSQL_DATABASE=drupal8/
-e MYSQL_USER=drupal8/
-e MYSQL_PASSWORD=drupal8/
-v mariadb:/var/lib/mysql/
-d/
--name mariadb/
mariadb
 

The first line means to create the container, the second to sixth lines are the database configuration parameters, -d is to run the container in the background, --name to give the container a name, and the last line is the image name.

The complete understanding is to create a container named mariadb running in the background from the mariadb mirror, and follow the established database configuration parameters. If there is no mariadb image locally, it will be automatically pulled from the Docker hub before creating the container.

The results of the operation are as follows:

Unable to find image 'mariadb:latest' locally
latest: Pulling from library/mariadb
5667fdb72017: Pull complete
d83811f270d5: Pull complete
ee671aafb583: Pull complete
7fc152dfb3a6: Pull complete
9f669c535a8b: Pull complete
a6de1092ee4e: Pull complete
ee37a2c88dd9: Pull complete
d927a3dd356c: Pull complete
d83c9d39c64f: Pull complete
1b0644883413: Pull complete
09a38adc2558: Pull complete
3c853415b952: Pull complete
2690cf0bfab9: Pull complete
3c68d64f060f: Pull complete
Digest: sha256:a32daf0281803fd96e86daf6b0293b4d476cede1b5ce80b18452dfa1405360ff
Status: Downloaded newer image for mariadb:latest
8cae72ad7ff02870c575c09eb3ad6f053c395287a3cfe17d7888991acc6cc254
 

The second step is to install the website server and Drupal source code

Enter the following command on the command line:

docker run/
--name drupal8/
--link mariadb:mysql/
-p 80:80/
-d/
drupal
 

The command means that the drupal image creates a container named drupal8 that runs in the background. If there is no Drupal image locally, it will be automatically pulled from the Docker hub before creating the container. --link The connection name is the mariadb container (created in the first step), and a link name is mysql. This name will be used in the third installation of Drupal. Remember! -p maps port 80 of the container to port 80 of the host, and you can directly access localhost in the browser of the host.

The results of the operation are as follows:

Unable to find image 'drupal:latest' locally
latest: Pulling from library/drupal
8f91359f1fff: Pull complete
bf2faaedf741: Pull complete
24cd1299a53e: Pull complete
17091cc665e4: Pull complete
ac9365919f9b: Pull complete
4f1b34e209ee: Pull complete
832757fa04a4: Pull complete
640a8cc59ee4: Pull complete
375d45a647bd: Pull complete
c265603c2115: Pull complete
b0b436e89a13: Pull complete
752098124903: Pull complete
baaf39033af6: Pull complete
eac75ead14e0: Pull complete
8494df29c26d: Pull complete
b9dd3d0f6cb9: Pull complete
Digest: sha256:899473656db6b2fb7343d9cfd8ab6493199b60500eed9d7202c0d2552c8c5b1d
Status: Downloaded newer image for drupal:latest
84d185875cd1e27c301042c743aab01757d3e9814557698b8d40a6b7b977e4ca
 

Since we did not specify the version number of the image when installing the container, we automatically pull the latest version, which means the latest version of the image.

After installing the two containers, we can view the containers and images in Docker. View the container:

docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                NAMES
84d185875cd1        drupal              "docker-php-entrypoi "   About an hour ago   Up About an hour    0.0.0.0:80->80/tcp   drupal8
8cae72ad7ff0        mariadb             "docker-entrypoint.s "   About an hour ago   Up About an hour    3306/tcp             mariadb
 

View the mirror:

docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
drupal              latest              4ae9d94d03b6        3 days ago          453MB
mariadb             latest              92495405fc36        12 days ago         356MB
 

The third part of the configuration website

Enter localhost in the browser of the host machine (the computer we are currently using) to start the Drupal installation page. Note that the database connection configuration:

In the database configuration parameters here, the database name, database user name, and database password are defined when we create the first container. They are all respectively drupal8. The host name in the advanced options is set when we create the second container. link The name of the link mysql.