Skip to content

ENV Variables Not Passing into Docker Environment #250

@sdananjay93

Description

@sdananjay93

Environment Variables are not getting exported into Docker Environment.

Steps to Reproduce

  1. execute run.sh as usual.
  2. Login into webserver image in an interactive console.

Output of finch ps

➜  2.10.3 git:(main) ✗ finch ps
CONTAINER ID    IMAGE                                                     COMMAND                   CREATED           STATUS    PORTS                                             NAMES
84a516cbf437    docker.io/amazon-mwaa-docker-images/airflow:2.10.3-dev    "/sbin/tini -- pytho…"    10 seconds ago    Up                                                          mwaa-2103-spy
658c75709d8f    docker.io/amazon-mwaa-docker-images/airflow:2.10.3-dev    "/sbin/tini -- pytho…"    10 seconds ago    Up                                                          mwaa-2103-worker
3f1f53440bb6    docker.io/amazon-mwaa-docker-images/airflow:2.10.3-dev    "/sbin/tini -- pytho…"    11 seconds ago    Up                                                          mwaa-2103-scheduler
a03f70c96718    docker.io/amazon-mwaa-docker-images/airflow:2.10.3-dev    "/sbin/tini -- pytho…"    11 seconds ago    Up        0.0.0.0:8080->8080/tcp                            mwaa-2103-webserver
d7e323169187    docker.io/softwaremill/elasticmq:latest                   "/opt/docker/bin/ela…"    11 seconds ago    Up        0.0.0.0:9324->9324/tcp, 0.0.0.0:9325->9325/tcp    2103-sqs-1
b455b6c2a2b3    docker.io/library/postgres:13                             "docker-entrypoint.s…"    12 seconds ago    Up        0.0.0.0:5432->5432/tcp                            mwaa-2103-db

Auto complete of ENV Variables available

➜  2.10.3 git:(main) ✗ finch exec -it a03f70c96718 bash
[airflow@webserver ~]$ echo $MWAA_
$MWAA_AIRFLOW_COMPONENT                             $MWAA__LOGGING__AIRFLOW_SCHEDULER_LOGS_ENABLED
$MWAA_COMMAND                                       $MWAA__LOGGING__AIRFLOW_SCHEDULER_LOG_GROUP_ARN
$MWAA_ESSENTIAL_CONSTRAINTS_FILE                    $MWAA__LOGGING__AIRFLOW_SCHEDULER_LOG_LEVEL
$MWAA_HOME                                          $MWAA__LOGGING__AIRFLOW_TASK_LOGS_ENABLED
$MWAA__CORE__AUTH_TYPE                              $MWAA__LOGGING__AIRFLOW_TASK_LOG_GROUP_ARN
$MWAA__CORE__CUSTOM_AIRFLOW_CONFIGS                 $MWAA__LOGGING__AIRFLOW_TASK_LOG_LEVEL
$MWAA__CORE__FERNET_KEY                             $MWAA__LOGGING__AIRFLOW_TRIGGERER_LOGS_ENABLED
$MWAA__CORE__KMS_KEY_ARN                            $MWAA__LOGGING__AIRFLOW_TRIGGERER_LOG_GROUP_ARN
$MWAA__CORE__MWAA_SIGNAL_HANDLING_ENABLED           $MWAA__LOGGING__AIRFLOW_TRIGGERER_LOG_LEVEL
$MWAA__CORE__REQUIREMENTS_PATH                      $MWAA__LOGGING__AIRFLOW_WEBSERVER_LOGS_ENABLED

Actual value of Environment Variables is empty

[airflow@webserver ~]$ echo $MWAA__CORE__STARTUP_SCRIPT_PATH

[airflow@webserver ~]$ echo $MWAA__CORE__FERNET_KEY

[airflow@webserver ~]$

Fix

Insert the following lines after exporting all variables in run.sh script

env | grep -E '^(AWS|MWAA)' > .env
set -a 
source .env
set +a

I am not exporting the FERNET_KEY, because 1) Due to special characters, the .env file generated is malformed, and 2) excluding it did not break the image or its execution.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions