【发布时间】:2021-09-18 17:58:08
【问题描述】:
我在 cmd 中运行docker-compose up airflow-init 以使用docker-compose.yaml 提供的模板部署 Airflow,创建文件夹日志、插件和 dag:
C:\Users\Diego\Airflow>dir
Volume in drive C has no label.
Volume Serial Number is 4296-D163
Directory of C:\Users\Diego\Airflow
09/18/2021 07:45 PM <DIR> .
09/18/2021 07:45 PM <DIR> ..
09/18/2021 07:45 PM 44 .env
09/18/2021 05:59 PM <DIR> dags
09/18/2021 05:52 PM 8,031 docker-compose.yaml
09/18/2021 07:44 PM <DIR> logs
09/18/2021 06:02 PM <DIR> plugins
2 File(s) 8,075 bytes
5 Dir(s) 22,549,196,800 bytes free
当命令运行时,给出的错误是:
C:\Users\Diego\Airflow>docker-compose up airflow-init
WARNING: The AIRFLOW_UID variable is not set. Defaulting to a blank string.
WARNING: The AIRFLOW_GID variable is not set. Defaulting to a blank string.
Creating network "airflow_default" with the default driver
Creating volume "airflow_postgres-db-volume" with default driver
Creating airflow_redis_1 ... done Creating airflow_postgres_1 ... done Creating airflow_airflow-init_1 ... done Attaching to airflow_airflow-init_1
airflow-init_1 | ERROR!!!: AIRFLOW_UID not set!
airflow-init_1 | Please follow these instructions to set AIRFLOW_UID and AIRFLOW_GID environment variables:
airflow-init_1 | https://airflow.apache.org/docs/apache-airflow/stable/start/docker.html#initializing-environment
从 docker 同步访问到文件夹时似乎出错,在 Linux 或 mac 中通过使用 echo -e "AIRFLOW_UID=$(id -u)\nAIRFLOW_GID=0" > .env 定义 env 变量文件来解决。
我尝试运行 echo 命令,这会导致在目录中创建 .env 文件,但这无助于让 airflow-init 在没有错误的情况下运行,因此这仅适用于 Linux,已安装的卷在容器中似乎无法使用 windows 文件系统用户/组权限,因此容器和主机没有匹配的文件权限。
如何在 Window 10 中使用 docker-compose 为气流正确设置环境变量?
Docker 桌面 4.0.1 步骤:
- 从 yaml Airflow 社区网页获取文件并将其放在一个目录中
- 在同一目录下创建文件夹日志、dags、插件
- 运行
docker-compose up airflow-init
【问题讨论】:
标签: docker docker-compose airflow