Dockerfile 权限被拒绝错误(Streamlit / OpenShift)

问题描述 投票:0回答:1

我使用来自 https://docs.streamlit.io/knowledge-base/tutorials/deploy/kubernetes 的模板 Dockerfile 来创建容器。构建运行并通过,但容器/pod 显示有关 run.sh 的错误:

错误:容器创建失败:time =“2023-11-07T23:40:52Z”level = error msg =“runc创建失败:无法启动容器进程:exec:“./run.sh”:权限被拒绝”

这里有什么问题吗?

请尊重 Dockerfile 中非常小的更改,因为我无法在那里使用 git clone。但这不是问题 - 问题是为什么 Streamlit 提供的这个“模板”不起作用。

FROM python:3.8-slim

RUN groupadd --gid 1000 appuser \
    && useradd --uid 1000 --gid 1000 -ms /bin/bash appuser

RUN pip3 install --no-cache-dir --upgrade \
    pip \
    virtualenv

RUN apt-get update && apt-get install -y \
    build-essential \
    software-properties-common \
    git

USER appuser
WORKDIR /home/appuser

# DELETED, BECAUSE NO REPO-ACCESS
RUN git clone https://github.com/streamlit/streamlit-example.git app

#THEREFORE ADDED (hope this is similar to the repo clone with ./app/?)
COPY main.py ./app/
COPY requirements.txt ./app/

ENV VIRTUAL_ENV=/home/appuser/venv
RUN virtualenv ${VIRTUAL_ENV}
RUN . ${VIRTUAL_ENV}/bin/activate && pip install -r app/requirements.txt

EXPOSE 8501

COPY run.sh /home/appuser
ENTRYPOINT ["./run.sh"]

文件 run.sh 也来自上面的页面,如下所示:

#!/bin/bash

APP_PID=
stopRunningProcess() {
    # Based on https://linuxconfig.org/how-to-propagate-a-signal-to-child-processes-from-a-bash-script
    if test ! "${APP_PID}" = '' && ps -p ${APP_PID} > /dev/null ; then
       > /proc/1/fd/1 echo "Stopping ${COMMAND_PATH} which is running with process ID ${APP_PID}"

       kill -TERM ${APP_PID}
       > /proc/1/fd/1 echo "Waiting for ${COMMAND_PATH} to process SIGTERM signal"

        wait ${APP_PID}
        > /proc/1/fd/1 echo "All processes have stopped running"
    else
        > /proc/1/fd/1 echo "${COMMAND_PATH} was not started when the signal was sent or it has already been stopped"
    fi
}

trap stopRunningProcess EXIT TERM

source ${VIRTUAL_ENV}/bin/activate

streamlit run ${HOME}/app/main.py &
APP_ID=${!}

wait ${APP_ID}#!/bin/bash

bash git docker dockerfile openshift
1个回答
0
投票

确保 Dockerfile 包含用于授予权限的适当语句。

在文件末尾添加此命令并再次运行脚本:

RUN chmod +x /home/appuser/run.sh

© www.soinside.com 2019 - 2024. All rights reserved.