docker - Airflow how to mount airflow.cfg in docker container
问题描述
I'm running airflow in a docker container and want to mount my airflow.cfg
as a volume so I can quickly edit the configuration without rebuilding my image or editing directly in the running container. I'm able to mount my airflow.cfg
as a volume and my airflow webserver successfully reads the configuration from it on start up. However, when I edit on the host changes aren't reflected inside the docker container.
The output for findmnt -M airflow.cfg
inside the docker container returns:
TARGET SOURCE FSTYPE OPTIONS
/usr/local/airflow/airflow.cfg /dev/sda1[/host/path/airflow/airflow.cfg~//deleted] ext4 rw,relatim
From that output it seems like airflow.cfg
continues to point to the original unedited version of airflow.cfg
. Is there any workaround to allow updating the config file from the host machine?
I'm using the LocalExecutor compose file from the puckel github repo as a base. I modify it to mount airflow.cfg
in the compose file instead of copying it in the Dockerfile.
解决方案
docker-compose.yml
我有同样的问题,我通过在 webserver 服务下添加以下行来解决它
- volumes:
- ./config/airflow.cfg:/usr/local/airflow/airflow.cfg
我的配置文件位于文件config
所在的docker-compose.yml
文件夹中。