gpt4 book ai didi

docker - 在Docker镜像中运行 Airflow 命令错误:[Errno 13]权限被拒绝:'/opt/airflow/logs/scheduler/

转载 作者:行者123 更新时间:2023-12-02 19:15:28 29 4
gpt4 key购买 nike

我正在从docker hubapache/airflow:latest顶部创建图像,该图像通过本地dag和插件复制。构建本地气流图像之后,我运行了docker run -it local_airflow:latest list_dags命令以列出最近复制的dag,但是得到了输出:

Unable to load the config, contains a configuration error.
Traceback (most recent call last):
File "/usr/local/lib/python3.6/logging/config.py", line 565, in configure
handler = self.configure_handler(handlers[name])
File "/usr/local/lib/python3.6/logging/config.py", line 738, in configure_handler
result = factory(**kwargs)
File "/home/airflow/.local/lib/python3.6/site-packages/airflow/utils/log/file_processor_handler.py", line 50, in __init__
os.makedirs(self._get_log_directory())
File "/usr/local/lib/python3.6/os.py", line 220, in makedirs
mkdir(name, mode)
PermissionError: [Errno 13] Permission denied: '/opt/airflow/logs/scheduler/2020-09-03'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/airflow/.local/bin/airflow", line 25, in <module>
from airflow.configuration import conf
File "/home/airflow/.local/lib/python3.6/site-packages/airflow/__init__.py", line 47, in <module>
settings.initialize()
File "/home/airflow/.local/lib/python3.6/site-packages/airflow/settings.py", line 402, in initialize
LOGGING_CLASS_PATH = configure_logging()
File "/home/airflow/.local/lib/python3.6/site-packages/airflow/logging_config.py", line 68, in configure_logging
raise e
File "/home/airflow/.local/lib/python3.6/site-packages/airflow/logging_config.py", line 63, in configure_logging
dictConfig(logging_config)
File "/usr/local/lib/python3.6/logging/config.py", line 802, in dictConfig
dictConfigClass(config).configure()
File "/usr/local/lib/python3.6/logging/config.py", line 573, in configure
'%r: %s' % (name, e))
ValueError: Unable to configure handler 'processor': [Errno 13] Permission denied: '/opt/airflow/logs/scheduler/2020-09-03'

这是基于基本气流图像构建的Dockerfile:
FROM apache/airflow:latest

USER airflow

ARG REQUIREMENTS_TXT=""
ENV REQUIREMENTS_TXT=${REQUIREMENTS_TXT}

COPY $REQUIREMENTS_TXT $REQUIREMENTS_TXT

ARG AIRFLOW_CONSTRAINTS_URL=""
ENV AIRFLOW_CONSTRAINTS_URL=${AIRFLOW_CONSTRAINTS_URL}

RUN if [ ! -z "${REQUIREMENTS_TXT}" ]; then pip install --user --upgrade pip && \
pip install --user -r "${REQUIREMENTS_TXT}" \
--constraint "${AIRFLOW_CONSTRAINTS_URL}"; fi

ARG DAGS_FOLDER="dags/"
ENV DAGS_FOLDER=${DAGS_FOLDER}

COPY dags/ $AIRFLOW_HOME/dags/

ARG PLUGINS_FOLDER="plugins/"
ENV PLUGINS_FOLDER=${PLUGINS_FOLDER}

COPY plugins/ $AIRFLOW_HOME/plugins/
这是docker build命令
docker build . \
--tag local_airflow:latest \
--build-arg DAGS_FOLDER="dags/" \
--build-arg PLUGINS_FOLDER="plugins/"

最佳答案

问题在于这些文件的所有者(几乎可以肯定)是root。因此,您无权在此进行任何更改。
我建议将COPY命令更改为如下形式:

COPY --chown=airflow ... ...
这会将文件/文件夹的所有权更改为气流。
有关更多信息,请查看文档: https://docs.docker.com/engine/reference/builder/#copy

关于docker - 在Docker镜像中运行 Airflow 命令错误:[Errno 13]权限被拒绝:'/opt/airflow/logs/scheduler/,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63719192/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com