Fast, isolated development environments using Docker.

Define your app's environment with Docker so it can be reproduced anywhere:

FROM python:2.7
ADD . /code
RUN pip install -r requirements.txt

Define the services that make up your app so they can be run together in an isolated environment:

  build: .
  command: python
   - db
   - "8000:8000"
  image: postgres

(No more installing Postgres on your laptop!)

Then type fig up, and Fig will start and run your entire app:

example fig run

There are commands to:

Quick start

Let's get a basic Python web app running on Fig. It assumes a little knowledge of Python, but the concepts should be clear if you're not familiar with it.

First, install Docker and Fig.

You'll want to make a directory for the project:

$ mkdir figtest
$ cd figtest

Inside this directory, create, a simple web app that uses the Flask framework and increments a value in Redis:

from flask import Flask
from redis import Redis
import os
app = Flask(__name__)
redis = Redis(host="redis_1", port=6379)

def hello():
    return 'Hello World! I have been seen %s times.' % redis.get('hits')

if __name__ == "__main__":"", debug=True)

We define our Python dependencies in a file called requirements.txt:


Next, we want to create a Docker image containing all of our app's dependencies. We specify how to build one using a file called Dockerfile:

FROM python:2.7
ADD . /code
RUN pip install -r requirements.txt

This tells Docker to install Python, our code and our Python dependencies inside a Docker image. For more information on how to write Dockerfiles, see the Docker user guide and the Dockerfile reference.

We then define a set of services using fig.yml:

  build: .
  command: python
   - "5000:5000"
   - .:/code
   - redis
  image: redis

This defines two services:

Now if we run fig up, it'll pull a Redis image, build an image for our own code, and start everything up:

$ fig up
Pulling image redis...
Building web...
Starting figtest_redis_1...
Starting figtest_web_1...
redis_1 | [8] 02 Jan 18:43:35.576 # Server started, Redis version 2.8.3
web_1   |  * Running on

Open up http://localhost:5000 in your browser (or http://localdocker:5000 if you're using docker-osx) and you should see it running!

If you want to run your services in the background, you can pass the -d flag to fig up and use fig ps to see what is currently running:

$ fig up -d
Starting figtest_redis_1...
Starting figtest_web_1...
$ fig ps
        Name                 Command            State       Ports
figtest_redis_1   /usr/local/bin/run         Up
figtest_web_1     /bin/sh -c python   Up      5000->5000/tcp

fig run allows you to run one-off commands for your services. For example, to see what environment variables are available to the web service:

$ fig run web env

See fig --help other commands that are available.

If you started Fig with fig up -d, you'll probably want to stop your services once you've finished with them:

$ fig stop

That's more-or-less how Fig works. See the reference section below for full details on the commands, configuration file and environment variables. If you have any thoughts or suggestions, open an issue on GitHub.