Skip to main content

Getting started with Drupal 10 and Docker

Submitted by daniel on

Let's have a quick look at how to set up a fresh Drupal 10 site using the Wodby Docker4Drupal boilerplate and the drupal-core-recommended install profile from Drupal's own drupal/recommended-project.

Requirements

You will need to have composer setup on your machine. When running php, I would recommend 8.1.x and one of the easiest ways to install on a Mac is using Homebrew. You will also need Docker Desktop installed.

Getting Started

Lets first create a a project containing the necessary composer setup, including composer.json file.

composer create-project drupal/recommended-project my-project

Substitute 'my-project' with your own project name

Next, lets download and unpack the contents of  docker4drupal.tar.gz from Wodby github with the latest stable release and copy them to your project root with the exception of the docker-compose.override.yml file. We don't want this file.

Before running the docker build, you probably want to check your settings that are specified in your .env file. 

PROJECT_NAME=my_drupal10_project
PROJECT_BASE_URL=drupal.internal
PROJECT_PORT=80

DB_NAME=my_drupal10_project

Let's have a look at these settings in a little more detail:

  1. PROJECT_NAME: These are used to crete the neccessary database and port mapping. In my experience when running multiple projects, to avoid conflicts, it's best to choose a unique project name.
  2. PROJECT_BASE_URL: Used to access your domain locally. personally I have a local DNS server set up that maps all .internal domains to localhost. Alternatively you can add your chosen domain to point at your localhost by also adding a line in your 'hosts' file
  3. PROJECT_PORT: To avoid port collisions this is set to 8000 by default. Pesonally I find that it is easier to work on the standard port 80, and this also makes setting up ssl on port 443 fairly trivial.
  4. DB_NAME: Again, if running mutiple environments, I would recommend choosing a unique name this project will use. This avoids a situation where 2 or more projects share the same docker hosted database.

Now you have configured everything to suit your requirements, go ahead and run your docker project in detached head mode.:

docker-compose up -d

Finally, go to the front end and hopefully you will see a brand new installed version of drupal at the install stage. Go ahead to and complete your drupal setup.

References

https://www.drupal.org/docs/develop/using-composer/starting-a-site-using-drupal-composer-project-templates#s-how-do-i-set-it-up

https://wodby.com/docs/1.0/stacks/drupal/local/#mount-my-codebase

Add new comment

Filtered HTML

  • Web page addresses and email addresses turn into links automatically.
  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.