-
Hi I've been tinkering around with the docker-compose instructions here. While customising the compose file (to support adding the airflow user to a docker group to allow access to /var/run/docker.sock) I became a little confused with the compose file's AIRFLOW_UID environment variable. The name suggests it's the UID for the "airflow" user within the containers. However, that's not possible as AIRFLOW_UID is set as a build argument for the upstream image on dockerhub. What appears to happen instead is the USER Dockerfile instruction is overridden & a new "default" user is added to passwd file using the environment variable AIRFLOW_UID. For example, see script below: foo@host:~/airflow-compose-test$ curl -LfO 'https://airflow.apache.org/docs/apache-airflow/2.0.2/docker-compose.yaml'
foo@host:~/airflow-compose-test$ mkdir ./dags ./logs ./plugins
foo@host:~/airflow-compose-test$ echo -e "AIRFLOW_UID=$(id -u)\nAIRFLOW_GID=0" > .env
foo@host:~/airflow-compose-test$ cat .env
AIRFLOW_UID=1000
AIRFLOW_GID=0
foo@host:~/airflow-compose-test$ docker-compose up airflow-init
...
airflow-init_1 | Admin user airflow created
airflow-init_1 | 2.0.2
airflow-compose-test_airflow-init_1 exited with code 0
foo@host:~/airflow-compose-test$ docker-compose run airflow-worker bash
Creating airflow-compose-test_airflow-worker_run ... done
BACKEND=postgresql+psycopg2
DB_HOST=postgres
DB_PORT=5432
default@a380ba45b47f:/opt/airflow$ id
uid=1000(default) gid=0(root) groups=0(root)
default@a380ba45b47f:/opt/airflow$ cat /etc/passwd
...
airflow:x:50000:0:,,,:/home/airflow:/bin/bash
default:x:1000:0:default user:/home/airflow:/sbin/nologin
default@a380ba45b47f:/opt/airflow$ groups
root Is that intentional? If it is, would it perhaps be better to rename AIRFLOW_UID in the docker-compose to another name like AIRFLOW_HOST_UID or better? Admittedly, I might be missing something too. Kind regs |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 13 replies
-
Yes. It is intentional. It is to allow to run arbitrary UID to run the image and make it OpenShift compatible. It is expleined in detain in the documentation https://airflow.apache.org/docs/docker-stack/entrypoint.html#allowing-arbitrary-user-to-run-the-container |
Beta Was this translation helpful? Give feedback.
Yes. It is intentional. It is to allow to run arbitrary UID to run the image and make it OpenShift compatible. It is expleined in detain in the documentation https://airflow.apache.org/docs/docker-stack/entrypoint.html#allowing-arbitrary-user-to-run-the-container