Fix Airflow Error: Missing AIRFLOW_UID Variable


👤 Diwas Poudel    🕒 31 Jul 2024    📁 TECH

When you try to run the Airflow Docker Compose file using docker compose up -d, you may encounter a warning like:

time="2024-07-31T23:00:37+05:45" level=warning msg="The \"AIRFLOW_UID\" variable is not set. Defaulting to a blank string."
time="2024-07-31T23:00:37+05:45" level=warning msg="The \"AIRFLOW_UID\" variable is not set. Defaulting to a blank string."

You can see warning as shown here:

 

To fix this, we will create a .env file at the same folder level as the docker-compose.yml file.

 

Inside the .env file, simply add the following lines of code.

AIRFLOW_UID=50000
AIRFLOW_GID=0

Here,

AIRFLOW_UID=50000 : This line assigns the user ID of 50000 to the Airflow process, meaning that the process will run under the user with this ID on the system. This is the default value for the Airflow user to prevent conflicts with other system users.

AIRFLOW_GID=0 : This sets the group ID for the Airflow process to 0, indicating that it will belong to the root group. This is typically done for permission reasons, enabling Airflow to access necessary files and directories.

After doing all these and again when you run docker-compose up -d you will not get any warning as shown here.

   

Conclusion: In this way, we resolved your Airflow warning while running the Docker Compose file.