Sitemap

Setting up Drupal 8 with Docker

3 min readJan 4, 2020

--

Press enter or click to view image in full size

Setting up Docksal

What you’ll realize messing about with Docker is that to get something like Drupal setup, it’ll require a fair bit of configuration to get things going with purely Docker. Enter Docksal. It’s a great, fast tool for running local web based projects, particularly Drupal. You can install it from https://docksal.io.

Creating the environment

Now that we have Docksal setup, we can fairly quickly get into setting up a Drupal site. The folks at Docksal have a decent boilerplate that can get things started: https://github.com/docksal/boilerplate-drupal8.

Once you’ve downloaded or git cloned the project into a directory on your system, getting it fired up is pretty straightforward. Open up a terminal window, and cd into your project folder. Assuming you have the site in a directory called boilerplate-drupal8 , once in the directory, run fin init , and you’ll see the process begin:

Press enter or click to view image in full size

Behind the scenes, Docksal is leveraging Docker to spin up a set of containers, each one running a required service for Drupal — The PHP / Apache server layer, the backend database, and a “CLI” container that allows you to interact with the entire stack. All of this is technically doable without Docksal, but Docksal gives you a head start!

Get Anonymous Hackers’s stories in your inbox

Join Medium for free to get updates from this writer.

Once the fin init completes, you’ll see that you now have a functional Drupal 8 site you can open in your browser:

Press enter or click to view image in full size
Press enter or click to view image in full size

Now you can mess around with the site as the user 1 super admin!

Customizing the code!

If you haven’t used Drupal console for writing modules, you definitely are going to want to! It greatly increases productivity writing custom Drupal 8 code by providing a wizard-like interface for scaffolding modules, services, fields, etc.. Let’s create a module for the new site. First, access the CLI container to interact with Drupal Console with fin bash .

Composer can sometimes take a second, but it’s worth the wait. If you have trouble running composer on the container itself, you can install it on your local host and run the composer require command from there instead. You may need to install composer locally, if you go this route. You can do that following the instructions for your OS here: https://getcomposer.org/doc/00-intro.md#introduction.

--

--

Anonymous Hackers
Anonymous Hackers

Written by Anonymous Hackers

0 followers

Anonymous Hackers