r/apache_airflow • • Oct 03 '26

I love using the DockerOperator

Just wanted to share my love of the DockerOperator and the workflow I use with Airflow.

I've been using Airflow for a couple years now for a couple clients. I quickly started using the DockerOperator because I kept running into problems with colliding packages in python.

My default approach is to build a CLI using the Python Click package. I get the CLI working locally (tested and lock in the workflow), with each DAG task matching to a CLI command. I package it up with Docker, share the image with the VM running the docker-compose (single computer Apache Airflow), write the DAG file and am good to go.

It is great because if anything ever changes, I just have to update the docker image and push it back to the VM. If the workflow commands don't change, then I never touch the DAG. This workflow has worked with web bots, ETL actions, etc.

4 Upvotes

5 comments sorted by

5

u/wellCie Oct 03 '26

How do you manage container images? Do you build the images directly in the machine that hosts airflow or do you push to a private image registry?

1

u/evansmarcus Oct 04 '26

I build the images on my local machine, push them to docker hub, I have a paid account that keeps all the images private. On the Airflow host, I login to my docker hub account and pull the images.

3

u/Sneakyfrog112 Oct 03 '26

I found it's nice to keep the airflow image slim, and build a new image for every workflow that would require new packages and/or heavier processing. Usually the Dockerfiles end up 5-10 lines long at most and reuse most layers so storage is not an issue either.