Getting Started (Compose)

Getting Started

On this page you build a simple Python web application running on Docker Compose. The application uses the Flask framework and increments a value in Redis. While the sample uses Python, the concepts demonstrated here should be understandable even if you’re not familiar with it.

Prerequisites

Make sure you have already installed both Docker Engine and Docker Compose. You don’t need to install Python, it is provided by a Docker image.

Step 1: Setup

  1. Create a directory for the project:

    $ mkdir composetest
    $ cd composetest
    
  2. With your favorite text editor create a file called app.py in your project directory.

    from flask import Flask
    from redis import Redis
    
    app = Flask(__name__)
    redis = Redis(host='redis', port=6379)
    
    @app.route('/')
    def hello():
        redis