Public | Automated Build

Last pushed: 2 years ago
Short Description
containers con la web de tnata
Full Description


This is a fork of the fantastic work made by Sean Boran
It's it thought to distribute a image or our company site (
It only adds the capability of import a database one the install process is done, but we still
need to think how to improve this cause it take years to complete.

If you have arrived here looking for a drupal container, please go to Docker-Drupal,
as we're just starting with Docker and want to have this merely for testing.

Following is just a copy of Docker-Drupal with some example on how to work with a custom .sql script mainly
for our devs.

Creates a Docker container for Drupal 7 or 8, using Linux (Ubuntu 14.04), Apache and MySQL:

  • Install Ubuntu 14.04/Apache/Php/Mysql with supervisord startup scripts
  • Install postfix to allow drupal to deliver emails
  • Install composer and drush
  • Use included Drupal7, or download Drupal, pull from git or via drush makefile
  • Install drupal+DB via a standard or custom profile
  • Optionally run cron, rsyslog and postfix, or add HTTPS, or externalise the DB, or..
  • Most drupal install settings are environment settings when creating a container from the image. See below.


Install docker if you dont have it yet.


Create a running container

Simplest form, start a D7 container:

docker run -td tantacom/tanta-docker

Start a D8 container:

docker run -td -e "DRUPAL_VERSION=drupal-8" tantacom/tanta-docker

Start a D7 container, interactive shell (run / when you have the shell to start lamp):

docker run -ti tantacom/tanta-docker /bin/bash

Name the container (--name drupal8003) and give it a public port (8003).
Then visit

docker run -td -p 8003:80 --name drupal8003 tantacom/tanta-docker


  • Examine log of the container started above (named drupal8003)
    docker logs -f drupal8003

  • connect a shell to the running container

    sudo docker exec -it drupal8003 bash

  • create a nice shell function in /etc/profile.d/, which allows one to do "nsenter CONTAINER-NAME"

    function nsenter (){ sudo docker exec -it $* bash; }

  • Create a new container and only run a shell
    docker run -ti tantacom/tanta-docker /bin/bash

Creating more complex containers

To run the container with "foo" as the admin password:

docker run -td -p 8003:80 -e "DRUPAL_ADMIN_PW=foo" -e "DRUPAL_SITE_NAME=My Super site" --name drupal8003 tantacom/tanta-docker

Drupal 8, set a password and title, mysql DB in on and mount /var/www/html from /opt/foo

docker run -td -p 8004:80 --name bc -e "DRUPAL_VERSION=drupal-8" -e "DRUPAL_ADMIN_PW=foo" -e "DRUPAL_SITE_NAME=My Super site" -e "MYSQL_HOST=" -e "MYSQL_DATABASE=drupal_site1" -e "MYSQL_USER=drupal_site1" -e "MYSQL_PASSWORD=pass4drupal_site1" -v /opt/foo:/var/www/html tantacom/tanta-docker

Download drupal+website on the develop branch from a https git repo:

docker run -td -p 8003:80 -e "DRUPAL_GIT_REPO=" -e "DRUPAL_GIT_BRANCH=devop" --name drupal8003 tantacom/tanta-docker

To run a custom install profile, set DRUPAL_INSTALL_REPO and DRUPAL_INSTALL_PROFILE accordingly.

Download drupal+modules according to a make file:

docker run -td -p 8003:80 -e "DRUPAL_MAKE_DIR=drupal-make1" -e "DRUPAL_MAKE_REPO=" -e "DRUPAL_MAKE_CMD=${DRUPAL_MAKE_DIR}/${DRUPAL_MAKE_DIR}.make ${DRUPAL_DOCROOT}" --name drupal8003 tantacom/tanta-docker`

For Tanta Devs

Crear contenedor con la web actual (drupal 6) importando la base de datos actual

docker run -t -p 8006:80 -p 33066:3306 -e "DRUPAL_VERSION=drupal-6" -e "CUSTOM_DB=/tantaweb.sql" -e "DRUPAL_GIT_REPO=https://[github_user]:[github_pass]" -e "DRUPAL_GIT_BRANCH=6.x" --name tanta6 -v /home/www/tanta6:/var/www/html tantacom/tanta-docker

Crear contenedor con el nuevo desarrollo (d8)

docker run -t -p 8006:80 -p 33066:3306 -e "DRUPAL_VERSION=drupal-8" -e "CUSTOM_DB=/tantacom-8.sql" -e "DRUPAL_GIT_REPO=https://[github_user]:[github_pass]" -e "DRUPAL_GIT_BRANCH=drupal-8" --name tanta6 -v /home/www/tanta8:/var/www/html tantacom/tanta-docker


  • 8006 es el puerto desde el que podrás acceder al desarrollo (http://localhost:8006)
  • 33006 puerto por el que podrás acceder al mysql del contenedor
  • github_user: tu usuario en github
  • github_pass: tu pass en github

Si quieres abrir una shell en cualquiera de los containers te bastaría con

docker exec -ti tanta6 /bin/bash

Donde tanta6 será el valor que hayas dado al parámetro --name cuando ejecutaste el docker run

Parameter reference

Environment parameters, defaults are as follows, commented values are not set by default:

    DRUPAL_SITE_NAME My Drupal Site
    DRUPAL_ADMIN admin

    #DRUPAL_VERSION drupal-7 
      By default a bundled drupal 7 is installed
      drush dl syntax, e.g.  drupal-7, drupal-7.x =dev, drupal-8.0.0-alpha15


    #DRUPAL_MAKE_DIR  drupal-make1
    # Which will run:  drush make ${DRUPAL_MAKE_DIR}/${DRUPAL_MAKE_DIR}.make ${DRUPAL_DOCROOT}
    Specify the repo and the branch of the install profile:

    # Run a feature revert revert after installing, can be useful for default content

    #If a second user is needed:
    # DRUPAL_USER1 bob
    # DRUPAL_USER1_PW bobspasswd
    # DRUPAL_USER1_ROLE manager     (if not specified, default is administrator)

    Optional mysql:
    # MYSQL_HOST is set, mysql will not be installed in the container

    Optional mysql+drupal
    # DRUPAL_NONE     (if set, mysql/drupal will not be installed)

    # Enable verbose debugging of


After drupal has been installed one may need to run some commands, e.g. set values via drush. There are two ways do do this.

  • DRUPAL_FINAL_CMD: Run a custom command after the site is installed. Example: get, enable and run the production check module "ENV DRUPAL_FINAL_CMD drush -y dl prod_check && drush -y en prod_check && drush -y cache-clear drush && drush -y prod-check-prodmode"
  • DRUPAL_FINAL_SCRIPT: Run a script after the site is installed. This script must already be available (i.e. pulled from a repo or make file during installation, or downloaded via a DRUPAL_FINAL_CMD. Example:
  • DRUPAL_FINAL_CMD=curl --silent -o /tmp/ && chmod 700 /tmp/

Install Drupal from a git repo with ssh keys

Download drupal+website on the master branch from a git repo via ssh with keys.

  • In this case an included script DRUPAL_GIT_SSH=/ is referenced which passes keys to ssh for use in git clone
  • Create ssh keys ( id_rsa) with ssh-keygen, stored in /root/boran-drupal/ssh
  • Then build the container mounting the SSH keys files under /root/gitwrap/id_rsa /root/gitwrap/
  • The example repo is

docker run -td -p 8003:80 -e "DRUPAL_GIT_SSH=/" -e "" -v /root/boran-drupal/ssh/id_rsa:/root/gitwrap/id_rsa -v /root/boran-drupal/ssh/ -v /root/boran-drupal/ssh/known_hosts/root/gitwrap/known_hosts --name drupal8003 tantacom/tanta-docker

Special cases

External database: MYSQL_HOST

If MYSQL_HOST is set, mysql will not be installed in the container.
In this case, create the DB first on your server and set the environment variables MYSQL_DATABASE MYSQL_USER DRUPAL_PASSWORD in addition to MYSQL_HOST.

No website: DRUPAL_NONE

By setting DRUPAL_NONE Its possible to setup a container with all tools and dependancies, but without a Drupal website. The first usee of this was creating a build container for continuous integration (see boran/docker-cibuild on github)

Postfix: email delivery

Postfix is installed since drupal needs to send emails during certain installation scenarios. If it cannot email, builds will break. The default installation will allow emails to be queued in postfix locally within the container.
To enabled full delivery ouside of the container, add appropriate lines to / inside the container e.g. change the relay to a SMTP mailgateway reachable from your network:

  echo " setup postfix, puppet. VIRTUAL_HOST=$VIRTUAL_HOST";
  postconf -e "myhostname = `hostname`"
  postconf -e 'mydestination = $VIRTUAL_HOST localhost.localdomain, localhost'
  postconf -e 'relayhost ='


By setting DRUPAL_SSL you enable ssl support in Apache. The preinstalled self signed certificate is used /etc/ssl/certs/ssl-cert-snakeoil.pem
To connect to port 443 via https map your port to port 443 (eg docker run -p 8443:443...)


By setting SUPERVISOR_CRON_ENABLE=true the cron daemon is started via supervisor.


By setting SUPERVISOR_RSYSLOG_ENABLE=true the syslog daemon is started via supervisor i.e. to catch and log events sent to syslog within the container.

Docker notes

Installing docker

If you have not yet got docker running, the following is one way to install on Ubuntu 14.04, pulling the latest version and ensuring aufs filesystem:

sudo apt-get install linux-image-extra-`uname -r`

sudo apt-key adv --keyserver hkp:// --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9

sudo sh -c "echo deb docker main\ > /etc/apt/sources.list.d/docker.list"

sudo apt-get update -qq && sudo apt-get -yq install lxc-docker

See also [using docker] (

Interative: stop/delete/rebuild:

docker stop drupal8003; docker rm drupal8003;
docker build -t="tantacom/tanta-docker" .

Run and look at logs:

docker run -td -p 8003:80 --name drupal8003 tantacom/tanta-docker
docker logs -f drupal8003


The very first iteration was based on a pattern from

Sean Boran

Docker Pull Command
Source Repository