首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Docker windows容器文件访问权限问题

Docker windows容器文件访问权限问题
EN

Stack Overflow用户
提问于 2017-11-15 16:08:10
回答 1查看 5.8K关注 0票数 3

Windows 2016主机,通过默认MSFTdocker提供程序运行Docker。 码头版本17.06.2-ee-5,构建508bb92 docker-构建版本1.17.1,构建6d101fb0

我有一个基于microsoft/windowsservercore:latest的Windows容器,并试图为竹服务器设置一个映像。在创建构建计划期间,服务器生成一个密码,用于竹类和Bitbucket之间的通信。在正在运行的容器中,密码文件夹/文件生成失败,出现以下错误:

代码语言:javascript
运行
复制
java.nio.file.AccessDeniedException: C:\bamboo-home\xml-data\configuration\cipher\cipher.key_0

我尝试将卷C:\bamboo-home连接到我的Windows主机上,并将其完全包含在容器中。两次都犯了同样的错误。

Windows容器使用一个名为“容器管理员”的管理员帐户运行;在默认映像中和在使用入口点时都是这样,如下所示。

标准图像运行:

代码语言:javascript
运行
复制
PS C:\> docker run -it microsoft/windowsservercore:latest powershell
Windows PowerShell Copyright (C) 2016 Microsoft Corporation. All
rights reserved.

PS C:\> whoami 
user manager\containeradministrator

和用于测试入口点的自定义映像:

代码语言:javascript
运行
复制
PS C:\test> docker-compose build
Building testentrypoint
Step 1/2 : FROM microsoft/windowsservercore:latest
---> 2cddde20d95d
Step 2/2 : ENTRYPOINT whoami
---> Running in 7fe31f02e45f
---> 60822e1907f1
Removing intermediate container 7fe31f02e45f
Successfully built 60822e1907f1
Successfully tagged test/entrypoint:latest
PS C:\test> docker-compose up
Creating network "test_default" with the default driver
Creating test_testentrypoint_1 ...
Creating test_testentrypoint_1 ... done
Attaching to test_testentrypoint_1
testentrypoint_1 | user manager\containeradministrator
test_testentrypoint_1 exited with code 0

据我所知,这个用户是管理员的别名,但有趣的是,它在net user中没有显示为这个名称:

代码语言:javascript
运行
复制
PS C:\> net user

User accounts for \\

-------------------------------------------------------------------------------
Administrator            DefaultAccount           Guest
The command completed with one or more errors.

因此,这是一个潜在的问题,但不管怎么说,根据我的判断,用户拥有完全的管理权限:

代码语言:javascript
运行
复制
PS C:\> $user = [Security.Principal.WindowsIdentity]::GetCurrent()
PS C:\> $user

AuthenticationType : Negotiate
ImpersonationLevel : None
IsAuthenticated    : True
IsGuest            : False
IsSystem           : False
IsAnonymous        : False
Name               : User Manager\ContainerAdministrator
Owner              : S-1-5-93-2-1
User               : S-1-5-93-2-1
Groups             : {S-1-1-0, S-1-5-32-545, S-1-5-6, S-1-2-1...}
Token              : 3052
AccessToken        : Microsoft.Win32.SafeHandles.SafeAccessTokenHandle
UserClaims         : {http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name: User Manager\ContainerAdministrator, http://schemas.microsoft.com/ws/2008/06/identity/claims/primarysid: S-1-5-93-2-1, http://schemas.microsoft.com/ws/2008/06/identity/claims/groupsid:
                     S-1-1-0, http://schemas.microsoft.com/ws/2008/06/identity/claims/groupsid: S-1-5-32-545...}
DeviceClaims       : {}
Claims             : {http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name: User Manager\ContainerAdministrator, http://schemas.microsoft.com/ws/2008/06/identity/claims/primarysid: S-1-5-93-2-1, http://schemas.microsoft.com/ws/2008/06/identity/claims/groupsid:
                     S-1-1-0, http://schemas.microsoft.com/ws/2008/06/identity/claims/groupsid: S-1-5-32-545...}
Actor              :
BootstrapContext   :
Label              :
NameClaimType      : http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name
RoleClaimType      : http://schemas.microsoft.com/ws/2008/06/identity/claims/groupsid

PS C:\> (New-Object Security.Principal.WindowsPrincipal $user).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
True

因此,我尝试了以下方法:

  1. 在容器中运行一个生成步骤,将文件夹权限设置为“每个人-完全访问”。
  2. 在启动时在正在运行的容器中手动运行脚本,该容器执行相同的操作。
  3. 在运行时连接到容器,并手动运行powershell以执行相同的操作

每次在尝试生成密码文件之前,权限如下所示:

代码语言:javascript
运行
复制
PS C:\> Get-ACL C:\bamboo-home\xml-data\configuration\ | fl

Path   : Microsoft.PowerShell.Core\FileSystem::C:\bamboo-home\xml-data\configuration\
Owner  : User Manager\ContainerAdministrator
Group  : User Manager\ContainerAdministrator
Access : Everyone Allow  FullControl
         NT AUTHORITY\SYSTEM Allow  FullControl
         BUILTIN\Administrators Allow  FullControl
         S-1-5-21-2465844383-291681238-1546083700-500 Allow  FullControl
Audit  :
Sddl   : O:S-1-5-93-2-1G:S-1-5-93-2-1D:AI(A;OICIID;FA;;;WD)(A;OICIID;FA;;;SY)(A;OICIID;FA;;;BA)(A;OICIID;FA;;;S-1-5-21-2465844383-291681238-1546083700-500)

上述错误在尝试生成后发生,权限更改为:

代码语言:javascript
运行
复制
PS C:\> Get-ACL C:\bamboo-home\xml-data\configuration\ | fl

Path   : Microsoft.PowerShell.Core\FileSystem::C:\bamboo-home\xml-data\configuration\
Owner  : User Manager\ContainerAdministrator
Group  : User Manager\ContainerAdministrator
Access : Everyone Allow  FullControl
Audit  :
Sddl   : O:S-1-5-93-2-1G:S-1-5-93-2-1D:AI(A;OICI;FA;;;WD)

为什么默认帐户(可能是名为容器管理员的管理员)在它似乎表明它有所有权的情况下会失去对这个目录的访问权?为什么它不能首先创建文件(或文件夹),因为在这两种情况下,“每个人”都应该有完全的访问权限?

EN

回答 1

Stack Overflow用户

发布于 2017-11-16 13:41:14

我没有识别主机/容器权限之间的问题,但是我提出容器的方式允许了这个问题的发生。通过更改我的设置过程,我能够纠正这个问题。

初始创建(创建文件夹的权限失败):

  1. 在主机上创建空白文件夹。
  2. 以卷的形式链接到容器内部文件夹(本例中所有C:\竹-home)。这是一个文件夹,竹将放置所有它的配置/工作区的东西。
  3. 在容器内安装产品,除密码文件夹失败外,一切正常工作。直到这一步才注意到问题。

新创建(工作正常):

  1. 在主机上创建空白文件夹。
  2. 以卷的形式链接到容器内部文件夹(在本例中为C:\空)。这并没有链接到C:\竹-home,它将根据需要在运行的容器中内部生成。
  3. 将产品安装在容器内。完成后,将所有文件从容器的文件夹复制到新建的空白文件夹中。这样,权限就以一致的方式设置在容器本身内,并缓解了以前出现的问题。
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47312143

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档