Part II: Drupal Docker Containers

During Part I we just started the shared Docker containers. For each Drupal Site we need an own Docker Container:


Find the right docker-compose.yml

  1. Visit or clone into a folder on your computer
  2. Copy the desired example file into your Drupal directory (see descriptions below). Use example-docker-compose-drupal.yml if unsure.
  3. Rename the file to docker-compose.yml
  4. Edit the file according to your needs, change at least the hostname. Btw: It's perfectly fine to commit this file into your git repo, so others that are also using docker can use it as well.
  5. Run in the same directory as the docker-compose.yml:

     docker-compose up -d
  6. If you are on Windows add the URL to the Hosts file (see windows documentation for that).
  7. Open your browser with the entered URL in the docker-compose.yml, happy Drupaling!

Connect to the container

To run commands like git or other things within the container, you need to connect to the container.

There are two ways for that:

Connect via docker-compose (easier)

This is the easier way, you need to be in the same folder where also the docker-compose.yml for that to work:

docker-compose exec --user drupal drupal bash

Connect via docker

If you want to connect to a container wherever you are right now with your bash:

docker exec -itu drupal bash

Replace with the docker container you want to connect to

Drush from your host machine

To use drush, you can either connect to the container as above, or add a bash function that will connect for you to run your drush command. To add the function, add this to your .bashrc file:


function ddrush() {
  while [ "$1" != "" ]; do
    args="${args} '$1'" && shift

  docker-compose exec --user drupal drupal bash -c "source ~/.bash_envvars && cd \"$AMAZEEIO_WEBROOT\" && PATH=`pwd`/../vendor/bin:\$PATH && drush ${args}"

Fish Shell - (

function ddrush --description 'Drush fish (friendly interactive shell) function that detects Docker container. '
  if test -f (git rev-parse --show-toplevel)/.amazeeio.yml
    echo "Using Docker Container Drush"
    command docker-compose exec --user drupal drupal bash -c "source ~/.bash_envvars && cd \"$AMAZEEIO_WEBROOT\" && PATH=`pwd`/../vendor/bin:\$PATH && drush $argv"
    command drush $argv

funcsave drush

When you next start a bash session, you'll be able to use ddrush just like your normal drush command.

SSH Agent

Per default your SSH Key at ~/.ssh/id_rsa is added to the Docker containers from either cachalot or pygmy

If you need another key, read the documentation of cachalot or pygmy about this.

Update Images

We constantly make improvements, updates and some other nice things to our container images. Visit to see if there is something new. If you need to update the Docker Images to the newest version from the Docker Hub run in the same folder as the docker-compose.yml:

docker-compose pull
docker-compose up -d

Slow Updates?

When pulling a new docker image, the download can get stuck. There is a nice workaround for that: pull a second time :)

Just open another terminal window at the exact same directory than you run the first docker-compose pull and just run that command again. The download will be unstuck and continue again. If the download is stuck again, cancel the second command with CTRL+c, and run it again (no worries, the first one will continue to run). Repeat that until the download is completely done.

docker-compose.yml example files

Example File PHP Services Description
example-docker-compose-drupal.yml 5.6/7.0/7.1 nginx, varnish, mariadb Drupal container without provisions for solr. See comments in file for choosing PHP version and customizing for Composer sites
example-docker-compose-drupal-solr.yml 5.6/7.0/7.1 nginx, varnish, mariadb, solr Drupal container with provisions for solr. See comments in file for choosing PHP version and customizing for Composer sites