Docker is a really sweet piece of tech. It is built on top of LXC and provides an abstraction to be able to easily build images for deployment.
I've been playing with Docker for a few hours and can definitely recommend it for easy deployments. What it does provide from traditional deployment strategies and configuration management is mostly speed and a standardized way to deploy different types of applications. Think of Docker as your own private PaaS.
When I first started out there was one thing I wanted to do, I wanted to deploy
a Sinatra application written in Ruby. To get started I decided to go with a
Dockerfile and write the steps to build the image and create a snapshot of it.
I'll be building this from an Ubuntu base box, so define that in the
Dockerfile and install
FROM ubuntu RUN apt-get install -y ruby rubygems
I felt that getting the artifact into the image was the tricky part, the documentation describes a way to insert a file from a URL and also a way to add a path from the local filesystem into the LXC container. Both of these commands however, did unfortunately not work in this version (it works if you specify add or insert via the CLI interface).
What I did was download it from a URL with
wget and untar it at a known
RUN wget http://example.com/sinatra-app.tar -O /opt/sinatra-app.tar RUN mkdir /opt/sinatra-app RUN tar xf /opt/sinatra-app.tar -C /opt/sinatra-app
I installed the dependencies with bundler and exported the port which Sinatra was going to run on:
RUN cd /opt/sinatra-app && bundle install ENV PORT 5000 EXPOSE PORT 5000
To build and run this Sinatra application, the following commands are being used:
docker build < Dockerfile # outputs the steps and hash, for example 9de15c84a9a1 docker run -d 9de15c84a9a2 foreman start -d /opt/sinatra-app # runs the newly built image and starts the app with foreman
To view the app, run
ID IMAGE COMMAND CREATED STATUS PORTS 96147c4d2090 9de15c84a9a1 foreman start -d /op Up 22 minutes 22 minutes ago 49171->5000
The port specified is the one that is forwarded on your host server, so if your
host server is
docker.example.com you'll see the app on
Docker seems like a great way to start out with nicer and better deployments for applications and services. I'm really looking forward to see what we can do with it and what others come up with to make it faster and easier to build new applications.