Using Docker on Travis CI
One of the most requested features over the past couple of months has been, without a doubt, the ability to use Docker as part of your builds. The use cases include building and shipping Docker images as part of the build, for instance based on build artifacts, or running tests or infrastructure components to closely model production environments based on Dockerfiles that are already part of your projects.
We’re pretty excited to announce that, as of today, you can use Docker as part of your build!
That means you can:
- Pull Docker images from central or private registries and start them up as part of your build.
- Set up a build environment that closely matches your development or production environments to run your tests.
- Set up an environment close to your production systems to run your code in and run your tests against.
- Build a Docker image before, after or during a successful build and ship it to a registry so you can use it on your staging or production systems.
How can I start using Docker?
There are a few additions you need to make to your .travis.yml
to have your builds be routed to our new stack:
sudo: required
services:
- docker
The addition of docker
in the services section can be combined with any other services you already have in your .travis.yml
.
What’s new in this new stack?
The infrastructure providing Docker in the environment is officially running on Ubuntu 14.04 Trusty Tahr. We’ll have more updates on the Trusty availability soon.
The default Docker version installed is currently 1.7.0. We’ll keep it up-to-date as we roll out new build environments, but you’re also free to install different versions of Docker as part your builds, the APT repository is added by default.
What’s included in the build environment?
As this new part of our infrastructure is still in its early stages, we’ve focused on supporting our most popular languages and work our way up from there.
We’ve included runtimes for Ruby, Node.js, Python and Go to begin with, so any of these languages, in combination with the .travis.yml
flags above, will get you started with the right build environment. All other languages will currently default to a trimmed down version of the build environment, which only includes Docker right now.
As for system services, we’ve focused on the minimum for now, which means that only the following services are available for now: MySQL, PostgreSQL, Memcached, RabbitMQ and Redis. The environment is currently missing ElasticSearch, MongoDB, and Riak.
If you need any further services or libraries, there are good news too: this new infrastructure has full sudo capabilities, so you can install packages you find missing.
We’re working on making more services and languages available as we improve this new stack on Travis CI.
For further details and examples on what you can do with this new stack, have a look at our documentation for running Docker as part of your build.
Here be dragons
We’re excited to make this new stack and the ability to fully utilize Docker in your builds available to you.
But this stack is still in its early stages. We’re improving the build environment just as we improve the infrastructure around it over the coming weeks. This also means that the environment may change in unexpected ways along the way. We’ll have more announcements related to this stack down the line.
You’ll also notice that boot times are still slower than what you’re used to on our container environment, which uses Docker internally to quickly boot up new containers, but we’re working on improving on that front too.
We’d love to hear about what you’re building with this new stack and with Docker on Travis CI. If you have any open source projects doing interesting things with it, leave a comment below. Or, should you have any troubles or questions, shoot us an email.
Happy shipping!