./run.sh: 21: source: Permission denied

Hello,

I’m trying to run locally for now docker container. I’ve used this docs, however I’ve modified a bit for my use case Dockerfile while leaving run.sh unchanged. While I’m trying to run container I’m getting:

./run.sh: 21: source: Permission denied
./run.sh: 23: streamlit: Permission denied
 was not started when the signal was sent or it has already been stopped

I have no clue why it is dropping error about permissions :confused: .
Dockerfile:

FROM python:3.11-slim

# This prevents Python from writing out pyc files
ENV PYTHONDONTWRITEBYTECODE=1

# This keeps Python from buffering stdin/stdout
ENV PYTHONUNBUFFERED=1

# avoid stuck build due to user prompt
ARG DEBIAN_FRONTEND=noninteractive

ENV LOG_LEVEL="" \
    LOG_SAMPLING_RATE="" \
    CURRENT_REGION="" \
    POWERTOOLS_SERVICE_NAME="" \
    SMB_USERNAME_SSM_PARAMETER_NAME="" \
    SMB_PASSWORD_SSM_PARAMETER_NAME="" \
    VIRTUAL_ENV=/home/docker_user/venv \
    PATH="/home/docker_user/venv/bin:$PATH" \
    PATH="/root/.cargo/bin:$PATH"

RUN apt-get update && apt-get install curl -y && \
    rm -rf /var/lib/apt/lists/*

# install uv
RUN curl -LsSf https://astral.sh/uv/install.sh | sh

# set up a virtual env to use for whatever app is destined for this container.
RUN uv venv --python 3.11.9 ${VIRTUAL_ENV}

# install requirements
COPY requirements.txt .
RUN uv pip install -r requirements.txt

RUN groupadd -g 1001 docker_group &&  \
    useradd -u 1001 -g 1001 -d /home/docker_user -ms /bin/bash -c "Docker image user" docker_user

COPY run.sh /home/docker_user

RUN chown -R docker_user:docker_group /home/docker_user
RUN chmod -R 755 /home/docker_user

USER docker_user

WORKDIR /home/docker_user

COPY admin.py /home/docker_user/app

EXPOSE 8083

ENTRYPOINT [ "./run.sh"]

Can you try running this script instead? Deploy Streamlit using Docker - Streamlit Docs

This is working, but I must use other than root user

Made it work, maybe you could update docs to have another example how to run it with uv (much better than pip) and a non root user:

FROM --platform=linux/amd64 public.ecr.aws/ubuntu/ubuntu:24.04 AS builder AS builder

# This prevents Python from writing out pyc files
ENV PYTHONDONTWRITEBYTECODE=1

# This keeps Python from buffering stdin/stdout
ENV PYTHONUNBUFFERED=1

# avoid stuck build due to user prompt
ARG DEBIAN_FRONTEND=noninteractive

ENV VIRTUAL_ENV=/app/venv \
    PATH="$VIRTUAL_ENV/bin:$PATH" \
    PATH="/root/.cargo/bin:$PATH" \
    PATH="/app/.cargo/bin:$PATH"

RUN apt-get update && apt-get install curl -y && \
    rm -rf /var/lib/apt/lists/*

RUN mkdir /app

RUN groupadd -g 1001 docker_group &&  \
    useradd -u 1001 -g 1001 -d /app -ms /bin/bash -c "Docker image user" docker_user

RUN chown -R docker_user:docker_group /app

USER docker_user
# install uv
RUN curl -LsSf https://astral.sh/uv/install.sh | sh

WORKDIR /app
COPY requirements.txt .
# set up a virtual env and install requirements
RUN uv venv --python 3.11.9 ${VIRTUAL_ENV}
RUN uv pip install -r requirements.txt

FROM --platform=linux/amd64 public.ecr.aws/ubuntu/ubuntu:24.04 AS builder AS appcontainer

ENV PATH=/app/venv/bin:$PATH
ENV PATH=/root/.cargo/bin:$PATH
ENV PATH=/app/.cargo/bin:$PATH

COPY --from=builder /app /app

COPY admin.py /app/admin.py

EXPOSE 8051

HEALTHCHECK CMD curl --fail http://localhost:8051/_stcore/health

ENTRYPOINT ["streamlit", "run", "/app/admin.py"]
1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.