Issue
I used this template Dockerfile from https://docs.streamlit.io/knowledge-base/tutorials/deploy/kubernetes to create a container. The build runs through and is passed, but the container/pod shows an error concerning run.sh:
Error: container create failed: time="2023-11-07T23:40:52Z" level=error msg="runc create failed: unable to start container process: exec: "./run.sh": permission denied"
Whats the problem here?
Please respect to the very small changes in the Dockerfile, because I cannot use git clone there. But this is not the question - the question it why this "template" offered from streamlit does not work.
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"]
The file run.sh is also from the page above an shown here:
#!/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
Solution
Make sure the Dockerfile contains an appropriate statement for granting permissions.
Add this command and run script again:
RUN chmod +x /home/appuser/run.sh
Answered By - Fernanda Answer Checked By - Cary Denson (WPSolving Admin)