Can't change the permissions of files/folders on a volume with Docker windows

半世苍凉 提交于 2021-02-08 10:22:42

问题


I tried to change the permissions of files/folders on a volume with Docker windows. But the permissions are not changed, unexpectedly.

Environment: Host: Windows 10 Pro Docker version 17.09.0-ce, build afdb6d4

Step to reproduce:

  1. Build a image with the Dockerfile below.
  2. Run a container with a volume.
  3. Change the permissions of files/folders.

Dockerfile:

FROM microsoft/windowsservercore
CMD [ "powershell" ]

Outputs:

D:\data\docker\sample>docker build -t sample .
Sending build context to Docker daemon  1.272GB
Step 1/2 : FROM microsoft/windowsservercore
 ---> 2cddde20d95d
Step 2/2 : CMD powershell
 ---> Running in dd207fe8b262
 ---> e0203df155cd
Removing intermediate container dd207fe8b262
Successfully built e0203df155cd
Successfully tagged sample:latest

D:\data\docker\sample>docker run -d --name sample --mount type=volume,source=sample_volume,target=C:/data sample ping -t localhost
5a21f41d63de321e912ec3b99010a062d2e04d5f99145c6cd8bf649d3fbbebf1

D:\data\docker\sample>docker exec -i sample cmd
Microsoft Windows [Version 10.0.14393]
(c) 2016 Microsoft Corporation. All rights reserved.

C:\>cd c:\data
cd c:\data

c:\data>MKDIR foo
MKDIR foo

c:\data>ECHO hoge > foo\hoge.txt
ECHO hoge > foo\hoge.txt

c:\data>cacls foo
cacls foo
c:\data\foo NT AUTHORITY\SYSTEM:(OI)(CI)(ID)F
            BUILTIN\Administrators:(OI)(CI)(ID)F
            CREATOR OWNER:(OI)(CI)(IO)(ID)F
            BUILTIN\Users:(OI)(CI)(ID)R
            BUILTIN\Users:(CI)(ID)(special access:)
                                  FILE_WRITE_DATA
                                  FILE_APPEND_DATA
                                  FILE_WRITE_EA
                                  FILE_WRITE_ATTRIBUTES



c:\data>cacls foo\hoge.txt
cacls foo\hoge.txt
c:\data\foo\hoge.txt NT AUTHORITY\SYSTEM:(ID)F
                     BUILTIN\Administrators:(ID)F
                     BUILTIN\Users:(ID)R


c:\data>cacls foo /T /E /G everyone:F
cacls foo /T /E /G everyone:F
processed dir: c:\data\foo
processed file: c:\data\foo\hoge.txt

c:\data>cacls foo
cacls foo
c:\data\foo NT AUTHORITY\SYSTEM:(OI)(CI)(ID)F
            BUILTIN\Administrators:(OI)(CI)(ID)F
            CREATOR OWNER:(OI)(CI)(IO)(ID)F
            BUILTIN\Users:(OI)(CI)(ID)R
            BUILTIN\Users:(CI)(ID)(special access:)
                                  FILE_WRITE_DATA
                                  FILE_APPEND_DATA
                                  FILE_WRITE_EA
                                  FILE_WRITE_ATTRIBUTES



c:\data>cacls foo\hoge.txt
cacls foo\hoge.txt
c:\data\foo\hoge.txt NT AUTHORITY\SYSTEM:(ID)F
                     BUILTIN\Administrators:(ID)F
                     BUILTIN\Users:(ID)R

I found a document which says that the permissions of files/folders on volumes cannot be changed on Linux containers. But I could not found documentation about Windows containers. Does Windows containers support the permission changes of file/folders on a volume on Windows containers?

Link:

  • Logs and troubleshooting | Docker Documentation https://docs.docker.com/docker-for-windows/troubleshoot/#permissions-errors-on-data-directories-for-shared-volumes

回答1:


From the link that you mentioned in question, it seems that docker for windows does not support changing file permissions.

Docker for Windows currrently implements host-mounted volumes based on the Microsoft SMB protocol, which does not support fine-grained, chmod control over these permissions.



来源:https://stackoverflow.com/questions/46597290/cant-change-the-permissions-of-files-folders-on-a-volume-with-docker-windows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!