DDev Docker

Alex Burrows
Nov 5, 2017 · 3 min read

So I attended NWDUG unconference this weekend with team Digidrop. During this there was a talk about Docker, now I’ve always been sceptical about Docker as I’ve had many issues and not much time to fix any issues I encounter, so I thought this session by Richard Sheppard would be ideal.

Richard explained about a docker tool called ddev (https://github.com/drud/ddev) which having tried many other types of docker tools I again was sceptical. However when it was explained it was as easy as 3 steps I was intrigued:

  1. Clone your repo or run composer for your site
  2. Using homebrew install ddev
  3. Run ddev config and ddev start

The process is as such:

Download ddev using homebrew

brew tap drud/ddev && brew install ddevbrew upgrade ddev

Download codebase

composer create-project drupal-composer/drupal-project:8.x-dev my-drupal8-site --stability dev --no-interaction cd my-drupal8-site

Configure and run

➜  my-drupal8-site ddev config
Creating a new ddev project config in the current directory (/Users/alexburrows/Sites/docker-play/my-drupal8-site)
Once completed, your configuration will be written to /Users/alexburrows/Sites/docker-play/my-drupal8-site/.ddev/config.yaml
Project name (my-drupal8-site):The docroot is the directory from which your site is served. This is a relative path from your application root (/Users/alexburrows/Sites/docker-play/my-drupal8-site)
You may leave this value blank if your site files are in the application root
Docroot Location: web
Found a drupal8 codebase at /Users/alexburrows/Sites/docker-play/my-drupal8-site/web
Configuration complete. You may now run 'ddev start'.
➜ my-drupal8-site ddev start
Starting environment for my-drupal8-site...
Starting ddev-my-drupal8-site-db ...
Starting ddev-my-drupal8-site-db ... done
Starting ddev-my-drupal8-site-dba ...
Starting ddev-my-drupal8-site-web ...
Starting ddev-my-drupal8-site-web
Starting ddev-my-drupal8-site-web ... done
Creating ddev-router ...
Creating ddev-router ... done
Starting service health checks...
Successfully started my-drupal8-site
Your application can be reached at: http://my-drupal8-site.ddev.local

Now any developer loves getting a local environment setup this quick, so it was a no brainer to use it. Once my environment was up and running I went through the installation process of Drupal.

The DB settings are:

DB name: db
Username: db
Password: db
Hostname: db

Then voila you are installed and setup.

Now looking inside the container, using: ddev ssh

You can see that the container uses the following by default:

root@c44ca233a8ff:/var/www/html/web# php -v
PHP 7.1.10-1+0~20170929170631.9+jessie~1.gbp501135 (cli) (built: Sep 29 2017 17:33:58) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
with Zend OPcache v7.1.10-1+0~20170929170631.9+jessie~1.gbp501135, Copyright (c) 1999-2017, by Zend Technologies
with Xdebug v2.5.5, Copyright (c) 2002-2017, by Derick Rethans

I’m still playing about with DDev, and the next step is to see if I can get Xdebug working with it, although from looking from the project issue queue it looks as if port 11011 is suppose to work, and running the following:

sudo ifconfig lo0 alias 172.28.99.99

So fingers crossed with some more tinkering I can get this working.

Adding extensions to DDEV

After speaking with Randy Fay and Rick Manelius about this (Drud team — https://drud.com) they suggested simply editing .ddev/config.yaml and adding the following to the end.

hooks:
post-start:
— exec: “apt-get update && apt-get install php7.2-bcmath”

Alex Burrows

Written by

Drupal Consultant, Technical Director at Digidrop (https://digidrop.io) and DrupalCamp London organisor - http://drupal.org/u/aburrows

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade