Skip to content

Instantly share code, notes, and snippets.

@bsmithgall
Last active August 29, 2015 14:21
Show Gist options
  • Save bsmithgall/43d1a26e56de0b36b74a to your computer and use it in GitHub Desktop.
Save bsmithgall/43d1a26e56de0b36b74a to your computer and use it in GitHub Desktop.
Docker compose example

This example is taken and a tiny bit modified from the docker-compose example. In order for this to work on OS, the easiest way is to install boot2docker, and docker-compose.

Once you have it installed:

boot2docker up
eval "$(boot2docker shellinit)"
boot2docker ip
# This will print the IP address of the VM, so you can access the machine
docker-compose up
from flask import Flask
from redis import Redis
redis = Redis(host="redis_1", port=6379)
app = Flask(__name__)
app.debug = True
@app.route('/')
@app.route('/<name>')
def index(name='world'):
redis_key = 'hits-{name}'.format(name=name)
redis.incr(redis_key)
return 'hello {name}! i have been seen {num} times'.format(
name=name, num=redis.get(redis_key)
)
if __name__ == '__main__':
app.run(host='0.0.0.0', port=9000)
web:
build: .
command: python app.py
links:
- redis
volumes:
- .:/app
ports:
- "9000:9000"
redis:
image: redis
FROM python:2.7
COPY . /app/
WORKDIR /app
RUN pip install -r requirements.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment