docker-airflow
docker-airflow copied to clipboard
How to set up airlfow variables?
Is it possible to set airflow variables in docker compose? I have a bunch of variables available as json and want to see how it can be supplied in docker compose file so that i can avoid the manual step of setting these variables when the code is migrated to diff envs. Can someone please help on this?
Hi, have you figured any way out to resolve this? Even I am facing the same issue.
Hi, have you figured any way out to resolve this? Even I am facing the same issue.
Not yet. One idea is to use the entrypoint.sh and docker file for airflow and then declare the variables there. But it wont give the comfort level in using this.
Variables are set in DB. So entrypoint is your bet.
Hi, just found that Airflow 1.10.10 can read variables from environment. There's a PR for upgrading to 1.10.11. See here https://airflow.apache.org/docs/stable/concepts.html?highlight=variable#storing-variables-in-environment-variables
I'm trying to set some variables from a JSON file for LocalExecutor. Could someone provide an example of how to set the variables? I'm kind of new to both airflow and docker.
I think I need to add the command airflow variables --import /path/to/variables.json
somewhere before or after the exec airflow webserver
line in the case statement
case "$1" in
webserver)
airflow initdb
if [ "$AIRFLOW__CORE__EXECUTOR" = "LocalExecutor" ] || [ "$AIRFLOW__CORE__EXECUTOR" = "SequentialExecutor" ]; then
# With the "Local" and "Sequential" executors it should all run in one container.
airflow scheduler &
fi
exec airflow webserver
airflow variables --import /path/to/variables # <----
;;
worker|scheduler)
I tried this, but no variables seem to get added
figured it out, I just reversed the lines, so
airflow variables --import /path/to/variables.json # <----
exec airflow webserver
airflow variables import /path/to/variables.json
it works for me