Email on failure/retry with airflow in docker container Email on failure/retry with airflow in docker container docker docker

Email on failure/retry with airflow in docker container


You don't need to do steps 1 and 2. Specify the environment variable in the docker-compose.yml.Also, make sure that you have enabled email sending on failure in the Operator,like in here: https://gist.githubusercontent.com/aawgit/0753b3ef1d715257e442ceafbc8583d3/raw/fa45caa9150e08654d476c2d619ab50615942b46/email-notification-on-task-failure.py


Set the following variables to make mail function work.It depends on the config of the SMTP mail server.User name and password should be set correctly.

  • If use docker-compose, setting the following variable in docker-compose.yml will auto update the airflow variables:
- AIRFLOW__SMTP__SMTP_HOST=smtp_host- AIRFLOW__SMTP__SMTP_PORT=25_?_the_smtp_port_used_smtp_host- AIRFLOW__SMTP__SMTP_USER=mail_user_name_of_your_app- AIRFLOW__SMTP__SMTP_PASSWORD=mail_user_password_of_your_app- AIRFLOW__SMTP__SMTP_MAIL_FROM=mail_user_name_of_your_app@mail.server.name
  • Similarly, if bring up docker manually, setting the following variables as environment variables:
AIRFLOW__SMTP__SMTP_HOST=smtp_hostAIRFLOW__SMTP__SMTP_PORT=25_?_the_smtp_port_used_smtp_hostAIRFLOW__SMTP__SMTP_USER=mail_user_name_of_your_appAIRFLOW__SMTP__SMTP_PASSWORD=mail_user_password_of_your_appAIRFLOW__SMTP__SMTP_MAIL_FROM=mail_user_name_of_your_app@mail.server.nameexport AIRFLOW__SMTP__SMTP_HOST AIRFLOW__SMTP__SMTP_PORT AIRFLOW__SMTP__SMTP_USER AIRFLOW__SMTP__SMTP_PASSWORD AIRFLOW__SMTP__SMTP_MAIL_FROM# Then bring up docker:docker run your_docker...