我正在我的Dockerfile中创建一个文件夹,我想给它一个写权限.但是当我尝试这样做时,我得到了许可被拒绝的错误
FROM python:2.7
RUN pip install Flask==0.11.1
RUN useradd -ms /bin/bash admin
USER admin
COPY app /app
WORKDIR /app
RUN chmod 777 /app
CMD ["python","app.py"]
我的错误是
PS C:\Users\Shivanand\Documents\Notes\Praneeth's work\Flask> docker build -t
shivanand3939/test .
Sending build context to Docker daemon 209.9kB
Step 1/8 : FROM python:2.7
---> 8a90a66b719a
Step 2/8 : RUN pip install Flask==0.11.1
---> Using cache
---> 6dc114bd7cf1
Step 3/8 : RUN useradd -ms /bin/bash admin
---> Using cache
---> 1cfdb6eea7dc
Step 4/8 : USER admin
---> Using cache
---> 27c5e8b09f15
Step 5/8 : COPY app /app
---> Using cache
---> 5d628573b24f
Step 6/8 : WORKDIR /app
---> Using cache
---> 351e19a5a007
Step 7/8 : RUN chmod 777 /app
---> Running in aaad3c79e0f4
**chmod: changing permissions of ‘/app’: Operation not permitted
The command '/bin/sh -c chmod 777 /app' returned a non-zero code: 1**
如何为Docker容器中的app文件夹授予写入权限
最佳答案
我猜你正在切换到用户“admin”,它没有更改/ app目录权限的所有权.使用“root”用户更改所有权. Dockerfile下面为我工作 –
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上面做这件事.