What is the correct permission for directories that will be used in airflow docker? #13855
-
Hi I want to run an airflow setup using the following docker-compose file
As you can see that I am going to use ~/airflow-data/ to store logs and ./airflow-dags to store dags file, when I start these containers using Also, what is the recommended way of storing logs and dags? Do you guys simply create a derived image using Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 11 replies
-
I think this is not a question of what are the permissions of the volumes, but about the ownership. The question is what user/groups should be used to run airflow. By default, Airflow user 50000:50000 to run using the prod image, however this user might not have access to the volumes, which will have HOST_USER/HOST_GROUP ownership/permission by default. Unfortunately in Linux, the mounted volumes in docker container use the native Linux filesystem user/group permissions, and this cannot be easily changed without changing the configuration of docker engine (userns-remap) and is not suitable for "developer" case as it requires engine-wide configuration changes and cannot be done per-container. There are plenty of guides in the internet suggesting changing permission/ownership inside the container, but they have a major drawback - the permissions are changed also in the host. However there is another option. Our image is OpenShift compatible, which means that you can run airlfow as any user, as long as the group of that user is set to "0". https://docs.openshift.com/container-platform/4.1/openshift_images/create-images.html#images-create-guide-openshift_create-images (look for "Support arbitrary user ids"). This means that you can run airflow using your HOST user id - example here: https://stackoverflow.com/questions/56844746/how-to-set-uid-and-gid-in-docker-compose (example here: https://dev.to/acro5piano/specifying-user-and-group-in-docker-i2e) but with UID = host user, GID = 0. Then you will be able to access the mounted volumes because they will be mounted as UID user. Let me know if it works. @mik-laj -> in your docker-compose solution I think we will need to do the same approach, however the (slight) problem it introduces is that you have to execute the docker-compose with UID=${UID} set as UID is shell rather than environment variable (docker/compose#4725). I am not aware of any other, better way. |
Beta Was this translation helpful? Give feedback.
I think this is not a question of what are the permissions of the volumes, but about the ownership.
The question is what user/groups should be used to run airflow. By default, Airflow user 50000:50000 to run using the prod image, however this user might not have access to the volumes, which will have HOST_USER/HOST_GROUP ownership/permission by default.
Unfortunately in Linux, the mounted volumes in docker container use the native Linux filesystem user/group permissions, and this cannot be easily changed without changing the configuration of docker engine (userns-remap) and is not suitable for "developer" case as it requires engine-wide configuration changes and cannot be done per-container.