Coder Social home page Coder Social logo

ptzagk / airflow-docker-compose-example Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dennisobrien/airflow-docker-compose-example

0.0 0.0 0.0 13 KB

Example implementation running Airflow as separate services with docker-compose.

Shell 25.30% Smarty 58.40% Dockerfile 16.31%

airflow-docker-compose-example's Introduction

airflow-docker-compose-example

Example implementation running Airflow as separate services with docker-compose.

This builds a docker container with a version of airflow that is built from a specific github repository/branch/commit. Edit this as you see fit.

Requirements

  • docker
  • docker-compose

Components

  • airflow webserver
  • airflow scheduler
  • airflow flower
  • airflow worker
  • mysql

Starting and Stopping the stack

First, make sure you are in the root directory of this repo.

Bring up the stack:

$ docker-compose up --force-recreate --build

The servers are now available here:

Bring the stack down:

$ docker-compose down --volumes

Building the Docker container

The Docker image will be built automatically with the command to bring up the stack, but if you really want to build it manually...

$ docker build --tag airflow:github .

Debugging

To get shell in the running docker container, first list the running processes.

$ docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED              STATUS              PORTS                                        NAMES
668a058847cd        airflow:github      "./wait-for-it.sh air"   About a minute ago   Up About a minute   8080/tcp, 0.0.0.0:5555->5555/tcp, 8793/tcp   airflowdockercomposeexample_airflow_flower_1
5ec419855460        airflow:github      "./wait-for-it.sh air"   About a minute ago   Up About a minute   5555/tcp, 8793/tcp, 0.0.0.0:8080->8080/tcp   airflowdockercomposeexample_airflow_webserver_1
4f4a7eeb8b50        airflow:github      "./wait-for-it.sh air"   About a minute ago   Up About a minute   5555/tcp, 8080/tcp, 8793/tcp                 airflowdockercomposeexample_airflow_worker_1
ab346e581b31        airflow:github      "./wait-for-it.sh db:"   About a minute ago   Up About a minute   5555/tcp, 8080/tcp, 8793/tcp                 airflowdockercomposeexample_airflow_scheduler_1
5e600b8d7e29        redis:3.2           "docker-entrypoint.sh"   About a minute ago   Up About a minute   6379/tcp                                     airflowdockercomposeexample_airflow_redis_1
da2262b20a60        mysql:5.7           "docker-entrypoint.sh"   About a minute ago   Up About a minute   0.0.0.0:3306->3306/tcp                       airflowdockercomposeexample_db_1

Now attach to any of the Airflow container processes you want to debug:

$ docker exec -it airflowdockercomposeexample_airflow_scheduler_1 bash
airflow@ab346e581b31:~$

Start an ipython shell and explore:

airflow@ab346e581b31:~$ ipython
Python 3.5.2 |Continuum Analytics, Inc.| (default, Jul  2 2016, 17:53:06) 
Type "copyright", "credits" or "license" for more information.

IPython 5.1.0 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]: from airflow import d[2016-12-01 01:24:37,398] {__init__.py:57} INFO - Using executor CeleryExecutor
In [1]: 

In [1]: from airflow import configuration

In [2]: from sqlalchemy import create_engine

In [3]: import pandas as pd

In [4]: engine = create_engine(configuration.get('core', 'SQL_ALCHEMY_CONN'))

In [5]: pd.read_sql("select dag_id, is_active from dag", engine)
Out[5]: 
                                     dag_id  is_active
0                     example_bash_operator          0
1            example_branch_dop_operator_v3          0
2                   example_branch_operator          0
3                     example_http_operator          0
4   example_passing_params_via_test_command          0
5                   example_python_operator          0
6            example_short_circuit_operator          0
7                          example_skip_dag          0
8                   example_subdag_operator          0
9         example_subdag_operator.section-1          0
10        example_subdag_operator.section-2          0
11           example_trigger_controller_dag          0
12               example_trigger_target_dag          0
13                             example_xcom          0
14                              latest_only          0
15                 latest_only_with_trigger          0
16                               test_utils          0
17                                 tutorial          0

airflow-docker-compose-example's People

Contributors

dennisobrien avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.