If you are not familiar with Docker you can read about it in my other article. In this article I'm talking specifically about docker-compose; the tool for building multiple containers (as most application stacks will require).

docker-compose is great. It can be used to deploy to your dev machines, your production application and of course your CI. I'm quite fond of Travis CI because it has seamless integration with Github, is free (for public repositories) and works very well with any type of project or build process you want to throw at it.

At the time of writing this Travis has most Docker tools preinstalled, but they are at older versions. So you will have to update them as part of the build script - this adds a little bit of time to the build and some time in the future you can remove that code.

I am going to assume you are familiar with the Travis YAML configuration. Here are the bits that matter:

env:
# You may want to update this to whatever the latest version is, or keep it
# the same as your local machines. However, I have only tested it with 1.8.0+.
# There should be a time in the future when this is not necessary - it is
# explained in more detail below.
DOCKER_COMPOSE_VERSION: 1.8.0

before_install:
# update is required to update the repositories to see the new packages for
# Docker.
- sudo apt-get update

# Now we can install the newer docker-engine which is required for the newer
# docker-composer we will install next. The messy options are to force it to
# be non-interactive (normally it asks you a bunch of config questions).
- sudo apt-get install -o Dpkg::Options::="--force-confold" --force-yes -y docker-engine

# Print out the current docker-compose version. Once this reports 1.6+ then we
# do not need the following steps.
- docker-compose --version

# As of the writing of this script Travis has docker-compose v1.4.2, we need
# to update it to 1.8+. $DOCKER_COMPOSE_VERSION is provide from the `env`
# above.
- sudo rm /usr/local/bin/docker-compose
- curl -L https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` > docker-compose
- chmod +x docker-compose
- sudo mv docker-compose /usr/local/bin

# Check that docker-compose is now running the latest version (or at least the
# one we specified). This is not to be confused with the version we printed
# before doing the update.
- docker-compose --version

# Setup your application stack. You may need to tweak these commands if you
# doing out-of-the-ordinary docker-compose builds.
- docker-compose pull
- docker-compose build
- docker-compose start

# You will want this for logging. If one of your containers does not build for
# whatever reason it's best to report that now before your tests start
# otherwise it can be really tricky to debug why tests are failing sometimes.
- docker ps

# This is just our script to setup all the database tables and other fixtures
# we need. You should remove this if it's not necessary or you have other
# scripts handling this.
- docker/web/provision.sh