Permission Denied for Open Json file in Docker Container

  Kiến thức lập trình

I met a problem after I run the docker container, it dockerize the streamlit (python) app. It looks the json file cannot load due to permission issue.

PermissionError: [Errno 13] Permission denied: 'inference_data/1234_photo_group.json' Traceback: File "/usr/local/lib/python3.9/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 541, in _run_script exec(code, module.__dict__) File "/app/app.py", line 128, in <module> gen_photo_group(report1_images, map_image_cap_1, "1234") File "/app/utils.py", line 188, in gen_photo_group with open("inference_data/" + report_id + "_photo_group.json", "w") as outfile:

Here is my docker file:

`FROM python:3.9-slim
EXPOSE 8080
RUN apt-get update && apt-get install -y 
    build-essential 
    curl 
    && rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY requirements.txt ./requirements.txt
COPY ./key.json /secret/key.json
RUN pip3 install -r requirements.txt
COPY . .
CMD streamlit run app.py --server.port=8080 --server.address=0.0.0.0`

Does it mean I need to grant permission in docker file? or other reason cause the permission issue. Thanks.

I tried to change the dockerfile, but it did not work. I need to know how to change the dockerfile to grant the permission or use other method to resolve this issue. Thanks.

New contributor

swing0829 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website

LEAVE A COMMENT