How to give folder permissions inside a docker container Folder

后端 未结 2 1847
我寻月下人不归
我寻月下人不归 2020-12-16 09:37

I am creating a folder inside my Dockerfile and I want to give it a write permission. But I am getting permission denied error when I try to do it

FROM pytho         


        
2条回答
  •  离开以前
    2020-12-16 10:16

    I guess you are switching to user "admin" which doesn't have the ownership to change permissions on /app directory. Change the ownership using "root" user. Below Dockerfile worked for me -

    FROM python:2.7
    RUN pip install Flask==0.11.1 
    RUN useradd -ms /bin/bash admin
    COPY app /app
    WORKDIR /app
    RUN chown -R admin:admin /app
    RUN chmod 755 /app
    USER admin
    CMD ["python", "app.py"] 
    

    PS - Try to get rid of "777" permission. I momentarily tried to do it in above Dockerfile.

提交回复
热议问题