Multi tier Docker apps with Fig

23Jul14

I had a play with Fig whilst researching my InfoQ story on Docker’s acquisition of Orchard Labs.

Rather than just going through the quick start guide and firing up their example app I thought I’d try out my own three tier demo from when I last wrote about multi tier apps with Docker. The three docker run commands get placed into a Fig config file[1]:

todomvcdb:
 image: cpswan/todomvc.mysql
 expose:
 - "3306"
 volumes:
 - /data/mysql:/var/lib/mysql
todomvcapp:
 image: cpswan/todomvc.sinatra
 expose:
 - "4567"
 links:
 - todomvcdb:db
todomvcssl:
 image: cpswan/todomvc.ssl
 ports:
 - "443:443"
 links:
 - todomvcapp:app

It’s as simple as that[2]. The application is then brought up using[3]:

sudo fig up

Whilst at one level this is simply moving complexity from one place (docker run) to another (fig.yml) the result is more manageable and elegant. I look forward to seeing what happens to Fig as the Orchard team integrate into Docker.

Notes:

[1] Sadly WordPress doesn’t support YAML with it’s code tag.
[2] Though I did need to remove the underscore separators I’d previously had e.g. todomvc_app.
[3] The need for sudo isn’t pointed out in the Fig docs :(