Drupal and Docker the easy way with Lando

Submitted by christophe on Mon, 05/03/2018 - 18:22

Ever thought about spinning up a Drupal 7 or 8 dev environment that is close to your production setup in minutes (Apache or Nginx, PHP 5.6 or 7.1, MySQL or Postgres, or ...)? Even better, you will be able to share the configuration with your team straight on your Git repository as a YAML file.

Lando provides development environments (LAMP, LEMP, MEAN, ...) and other recipes for Drupal 6 to 8, Laravel, Backdrop, ... .

Lando is for developers who want to quickly specify and painlessly spin up the services and tools needed to develop their projects. It's a free, open source, cross-platform, local development environment and DevOps tool built on Docker container technology.

Install Lando

For Mac OS, download the latest version on GitHub.
More info and other platforms

Init a Drupal 8 environment

Lando strength is close to zero configuration. You can override it if needed, but by default your setup for this recipe will be Apache, PHP 7.1 and MySQL 5.7.

# Create a Drupal project. Assumes that you have Composer installed.
composer create-project drupal-composer/drupal-project:8.x-dev my_drupal_project --stability dev --no-interaction

# Cd into the created directory.
cd my_drupal_project

# Launch the interactive session.
lando init

# Or just specify the Drupal 8 recipe.
lando init --recipe drupal8

Lando init

Get app information

lando info

This command will print the default config from the recipe : PHP version, MySQL credentials, ...

  "appserver": {
    "type": "php",
    "version": "7.1",
    "via": "apache",
    "webroot": "web",
    "config": {
      "conf": "/Users/christophe/.lando/services/config/drupal8/php.ini"
  "database": {
    "type": "mysql",
    "version": "latest",
    "creds": {
      "user": "drupal8",
      "password": "drupal8",
      "database": "drupal8"
    "internal_connection": {
      "host": "database",
      "port": 3306
    "external_connection": {
      "host": "localhost",
      "port": true
    "config": {
      "confd": "/Users/christophe/.lando/services/config/drupal8/mysql"


Start your environment

lando start

Noticed the enabled SSL? Sweet!

Lando start


Install your site with Drush

lando drush site-install standard --account-name=admin --account-pass=admin --db-url='mysql://drupal8:[email protected]/drupal8' --site-name=Dev85

Site installed

Among other tools, in the Drupal 8 recipe, we now have

  • lando composer
  • lando db-import / db-export
  • lando drupal
  • lando mysql
  • lando php

Just run `lando` for a complete list of commands.

Add a service

Optionaly if you want to finetune your setup, go to the .lando.yml file.
As an example, here we will add Mailhog to catch outbound mails:

# Configuration provided by the `lando init` command.
name: drupal-85-dev
recipe: drupal8
  webroot: web

# Proxy settings so we get a nice URL for the mailhog ui.
    - mail.drupal8.lndo.site
  # Spin up a mailhog container called "mailhog" or whatever, the name is arbitrary.
    # Use the latest version
    type: mailhog
    # Mailhog expects that these services will be php services.
      - appserver
    # Optional access at localhost:1026
    portforward: 1026

Then restart Lando.

lando restart

Lando Mailhog

Now Elasticsearch, Solr, Varnish, Redis, Mongo, ... are at your fingertips ?

Here is a starter for several databases, MailHog, PhpMyAdmin. If you modified your existing configuration, run `lando rebuild` then.



Hey There!

Awesome to see some of the example configurations in this setup! For anybody curious of trying out Lando, if you have questions, we have a community slack channel you can join here: https://launchpass.com/kalabox

Thanks for the shoutout!

This might be a very stupid question, but I couldn't find an answer. If I create several drupal sites from scratch with lando, do I use --db-url='mysql://drupal8:[email protected]/drupal8' for all of them? Or do I create different databases, if so how?

I was asking myself the same. Check out the hostnames part under lando info, the different hostnames allow multiple databases with same name ("drupal8") since they are under different hostnames, named according to the name of the folder lando is in.
"database": {
"type": "mysql",
"version": "5.7",
"hostnames": [
"creds": {
"user": "drupal8",
"password": "drupal8",
"database": "drupal8"

Add new comment

Restricted HTML

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.