Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 919
hamdog Avatar asked Dec 13 '22 12:12

hamdog


1 Answers

I had the same issue and I solved it by adding the following line to docker-compose.yml, under the webserver service

- volumes:
  - ./config/airflow.cfg:/opt/airflow/airflow.cfg

I have my config file in a folder called config where the docker-compose.yml file is.

like image 58
Saverio Guzzo Avatar answered Jan 05 '23 19:01

Saverio Guzzo