且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在Docker容器内授予文件夹权限

更新时间:2021-12-05 21:40:37

我想您正在切换为用户"admin",该用户无权更改/app目录的权限.使用"root"用户更改所有权.下面的Dockerfile为我工作-

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-尝试摆脱"777"权限.我暂时尝试在上述Dockerfile中做到这一点.

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