[note] 修正 apache/airflow:2.10.2 Docker 映像中 Git 安裝問題

註記:此頁為由 AI(gpt-5-mini-2025-08-07)自動翻譯自英文原文,可能含有少量不準確之處。

📌 介紹

The article discusses the issue of permission errors when attempting to install packages from GitHub while using the apache/airflow:2.10.2 Docker image. It presents a solution that involves temporarily switching to the root user to install ‘git’ and then reverting to the airflow user for further installations.

🚀 快速開始

1
2
3
4
5
6
7
8
FROM apache/airflow:slim-2.10.2

USER root
RUN apt-get update && apt-get install -y git

USER airflow
COPY requirements.txt requirements.txt
RUN pip install --no-cache-dir -r requirements.txt

🔁 重點回顧

  • 使用 apache/airflow:2.10.2 映像從 GitHub 安裝套件時,可能會發生權限錯誤。
  • 為了解決此問題,請在切回 airflow 使用者之前,以 root 使用者身分安裝 git。
  • 範例 Dockerfile 示範了執行這些操作的步驟。
作者

Hsiang-Jen Li & ChatGPT-4o Mini

發表於

2024-09-26

更新於

2025-02-28

許可協議