'Visual Studio Code - Remote Containers - UID Issue

I am using a standard airflow image as the base image for a custom Airflow image. I then use the custom Airflow image as the image for Visual Studio Code Remote Containers. The problem I am facing are permissions issues on the workspace folder or the AIRLOW_HOME directory depending on the configuration.

The standard Airflow image uses the following UID when creating the base image

ARG AIRFLOW_UID="50000"

The workspace folder is mounted as my host user with the ID of 1000. Here is my devcontainer configuration which says use the airflow account when running all the Visual Studio Code processes including terminal sessions but do not change the UID of the airflow user.

{
"build": {
    "dockerfile": "Dockerfile",
    "args": {
        "BASE_AIRFLOW_IMAGE": "apache/airflow:2.2.5-python3.8"
    }
},
"extensions": [
    "ms-python.python"
],
"containerEnv": {
    "AIRFLOW__CORE__DAGS_FOLDER": "${containerWorkspaceFolder}"
},
"runArgs": [
    "--network=host"
],
"postStartCommand": "airflow db init",
"remoteUser": "airflow",
"updateRemoteUserUID": false

}

So the issue for me is that workspace files are owned by the host user which has a UID of 1000. If I set the flag to true then the AIRFLOW home directory which is owned by 50000 fails to to be writable.

What I have not done:

  • Set the AIRFLOW HOME directory to be a folder in the workspace and set updateRemoteUserUID to true so that the AIRFLOW user gets a UID of 1000.
  • Write a build time script that changes the ownership of the AIRFLOW_HOME directory and the contained filesto the UID of 1000

What I did do is on the host machine just set the UID of the files to be 50000.

Any suggestions on how to deal with this?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source