Updated on 2014-01-18
Docker is the Linux container engine. It gives developers the ability to "pack, ship and run any application as a lightweight container". Docker containers can include applications along with all necessary dependencies. It also manages startup, port mapping/networking and resource allocation. Furthermore Docker tracks changes on a copy-on-write filesystem (AUFS) to enable a change graph - similar conceptually to a VCS like Git - so containers may be built from other containers and only the differences need to be stored.
Let's take the example of an open source application we maintain: StriderCD, a continuous integration server written in JavaScript. Strider is similar to Jenkins or TravisCI but with an emphasis on ease of setup, private deployments and is designed from the ground up to be highly customizable through plugins.
StriderCD consists of a Node.JS application server and so it requires Node be installed. It also uses MongoDB, so it needs a MongoDB database for persistence.
We can create a Docker container from the Ubuntu base image and then install a recent version of Node.JS, along with Strider itself and MongoDB process. We can then distribute this container as an image over the internet via the Docker Index.
The very talented Strider contributor Jared Forsyth [github] implemented precisely this in his awesome Strider Dockerfile on Github.
Once you have Docker installed on a machine, it's very easy to get your own Strider instance up. Simply run the command:
$ docker pull niallo/striderThis will download the official Strider Trusted Build Docker image. It can take a few minutes to download the various layers, so be patient.
Once this has completed successfully, you should see the Strider image in your Docker images list:
Now that you have the Strider Docker image available, you can run it. The Strider Docker image exposes the following ports from inside the container: 3000 (Strider itself), 22 (SSHD) and 27071 (MongoDB).
By default, Docker will randomly select ports on the Docker host to map to those internal ports. However, you can supply them on the command line. So, to have port 3000 on our host map to port 3000 in the Strider container, we can run:
$ docker run -d -p 3000:3000 niallo/striderOr if we wished to also map SSHd and MongoDB to ports 44 and 27017 respectively:
$ docker run -d -p 3000:3000 -p 27000:27017 -p 44:22 niallo/striderNow if you run
docker ps
you should see your Strider container running:
Strider is now accessible from your Docker host on port 3000. Assuming you are running Docker on localhost, if you browse to you should see the homepage for your personal Strider-in-a-box!
Vagrant Usage
NOTE: If you are running Docker in Vagrant (as many OS X users do) you will need to make sure Strider's port 3000 inside the VM is mapped to your host. Read about Vagrant port mappings here.
You can now log in. The default admin user for the Dockerized Strider is:
email: password: dontlook
Security note Of course, it isn't wise to leave the default password in place - you should delete this user from MongoDB as soon as you create a new admin user with a secure password. The query to do so is:db.users.remove({email:""})Run this against the strider-foss database.
We hope you have found Strider's Dockerfile a super easy way to get a continuous integration server up and running on your own local machine.
For a real production, internet-accessible Strider deployment, you'll need to do a little more work. You'll have to create your own Github Application for domains other than localhost
and you might want to use a more reliable external MongoDB cloud host such as MongoLab. You'll also want to configure an SMTP server for test success/failure notification emails (we use Mailgun).
In order to do this, you'll need to customize things. Strider is configured via environment variables. Environment variables can be passed through to Docker with the -e KEY=VAL
syntax. For example:
Read more about configuring Strider in the README.md.
If you need help installing, hosting or customizing Strider, we provide commercial support and services (custom continuous integration plugins, branded test dashboards, etc). Shoot us an email at or use the contact form on our website at frozenridge.co.