【发布时间】:2018-04-28 22:58:57
【问题描述】:
Windows Server 2016 主机,通过默认的 MSFTdocker 提供程序运行 Docker EE。
Docker 版本 17.06.2-ee-5,构建 508bb92
docker-compose 版本 1.17.1,构建 6d101fb0
我有一个基于 microsoft/windowsservercore:latest 的 Windows 容器,并且正在尝试为 Bamboo 服务器设置映像。在创建构建计划期间,服务器会生成密码以在 Bamboo 和 Bitbucket 之间进行通信。在正在运行的容器中,密码文件夹/文件生成失败并出现以下错误:
java.nio.file.AccessDeniedException: C:\bamboo-home\xml-data\configuration\cipher\cipher.key_0
我已尝试将卷 C:\bamboo-home 都附加到我的 Windows 主机,并完全包含在容器中。两次同样的错误。
Windows 容器使用名为“containeradministrator”的管理员帐户运行;在默认图像和使用入口点时都是这种情况,如下所示。
标准图像运行:
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
并在定制图像上测试入口点:
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 中:
PS C:\> net user
User accounts for \\
-------------------------------------------------------------------------------
Administrator DefaultAccount Guest
The command completed with one or more errors.
所以这可能是一个问题,但无论如何,据我所知,用户拥有完整的管理员权限:
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
所以我尝试了以下方法:
-
在容器中运行一个构建步骤,将文件夹权限设置为“所有人 - 完全访问”
-
在启动时在运行的容器中手动运行脚本
-
运行时连接容器,手动运行powershell也一样
每次尝试生成密码文件之前,权限如下所示:
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)
并且尝试生成后出现上述错误,权限更改为:
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)
为什么默认帐户(可能是名为 containeradministrator 的管理员)在似乎表明它拥有所有权时会失去对该目录的访问权限?为什么它不能首先创建文件(或文件夹),因为在这两种情况下,“每个人”都应该拥有完全访问权限?
【问题讨论】:
-
您能否仅使用 Microsoft 库重现该问题。您一直在谈论
generation进程和之后对文件系统的更改,这是外部进程,似乎在这里表明此行为是 curlpit 而不是容器运行时。 -
嘿格雷格,绝对不要不同意。问题是外部进程应该(作为“每个人”的一部分)有权访问此文件夹以随意读取/写入,并且似乎写入没有按设计工作。我不知道是否会有一种仅使用 Microsoft 库重新创建它的好方法。
-
这个过程是在修改权限吧?那你到底在问什么?
-
由于文件夹权限问题,无法创建进程需要创建的文件“cipher.key_0”。我想知道为什么在我在这个容器中尝试过的任何情况下它都无法写入文件夹。
-
但是这个权限问题是由第三方实用程序修改权限引起的,对吧?还要检查文件夹更改后
InheritanceFlags对每个人的用途,你必须为它做fl *
标签: powershell docker windows-server windows-container windows-server-container