Running Drupal in Docker
#Drupal #Docker #InstallGuide
Full steps can be found at https://i12bretro.github.io/tutorials/0809.html
--------------------------------------------------------------------
What is Drupal?
--------------------------------------------------------------------
Drupal is content management software. It's used to make many of the websites and applications you use every day. Drupal has great standard features, like easy content authoring, reliable performance, and excellent security. - https://www.drupal.org/about
--------------------------------------------------------------------
Installing Docker
--------------------------------------------------------------------
01. Log into the Linux based device
02. Run the following commands in the terminal
# install prerequisites
sudo apt install apt-transport-https ca-certificates curl software-properties-common gnupg-agent -y
# add docker gpg key
curl -fsSL https://download.docker.com/linux/$(awk -F'=' '/^ID=/{ print $NF }' /etc/os-release)/gpg | sudo apt-key add -
# add docker software repository
sudo add-apt-repository "deb [arch=$(dpkg --print-architecture)] https://download.docker.com/linux/$(awk -F'=' '/^ID=/{ print $NF }' /etc/os-release) $(lsb_release -cs) stable"
# install docker
sudo apt install docker-ce docker-compose containerd.io -y
# enable and start docker service
sudo systemctl enable docker && sudo systemctl start docker
# add the current user to the docker group
sudo usermod -aG docker $USER
# reauthenticate for the new group membership to take effect
su - $USER
--------------------------------------------------------------------
Running the Drupal Container
--------------------------------------------------------------------
01. Now that Docker is installed, run the following commands to setup the Drupal Docker container and run it
# create working directories
mkdir ~/docker/drupal -p && mkdir ~/docker/mariadb -p
# set ownership on the working directories
sudo chown "$USER":"$USER" ~/docker -R
# create containers network
docker network create containers
# run the mariadb docker container
docker run -d --name mariadb -e MYSQL_ROOT_PASSWORD=r00tp@$$ -e MYSQL_USER=drupal_rw -e MYSQL_PASSWORD='Dru4@l!!' -e MYSQL_DATABASE=drupal -v ~/docker/mariadb:/var/lib/mysql --network containers --restart unless-stopped mariadb
# initialize the drupal application files
docker run --rm drupal tar -cC /var/www/html . | tar -xC ~/docker/drupal
# make a copy of default.settings.php
cp ~/docker/drupal/sites/default/default.settings.php ~/docker/drupal/sites/default/settings.php
# create the files directory
mkdir ~/docker/drupal/sites/default/files
# allow the container to write to files/ and settings.php
sudo chmod a+rwx -R ~/docker/drupal/sites/default/files
sudo chmod a+rwx -R ~/docker/drupal/sites/default/settings.php
# run the drupal docker container
docker run -d --name=drupal -p 8880:80 -v ~/docker/drupal/modules:/var/www/html/modules -v ~/docker/drupal/profiles:/var/www/html/profiles -v ~/docker/drupal/sites:/var/www/html/sites -v ~/docker/drupal/themes:/var/www/html/themes --network containers --restart unless-stopped drupal
02. Open a web browser and navigate to http://DNSorIP:8880
03. The Drupal setup screen should be displayed
04. Select a language ≫ Click Save and continue
05. Select the Standard profile ≫ Click Save and continue
06. Enter the database name, username and password ≫ Expand Advanced and set the Host value to mariadb (the mariadb container name) ≫ Click Save and continue
07. Create a site title and Drupal login ≫ Click Install Drupal
08. When the installation completes, enter a site name, email address, username and password ≫ Click Save and continue
09. Welcome to Drupal
Documentation: https://hub.docker.com/_/drupal
### Connect with me and others ###
★ Discord: https://discord.com/invite/EzenvmSHW8
★ Reddit: https://reddit.com/r/i12bretro
★ Twitter: https://twitter.com/i12bretro