次の方法で共有


gMSA を使用してコンテナーを実行する

適用対象: Windows Server 2025、Windows Server 2022、Windows Server 2019

グループ管理サービスアカウント (gMSA) を使用してコンテナーを実行するには、資格情報仕様ファイルを --security-opt パラメータに指定して docker runを使用します。

docker run --security-opt "credentialspec=file://contoso_webapp01.json" --hostname webapp01 -it mcr.microsoft.com/windows/server:ltsc2022 powershell

重要

Windows Server 2016 バージョン 1709 および 1803 では、コンテナーのホスト名が gMSA の短い名前と一致している必要があります。

前の例では、gMSA SAM アカウント名が webapp01であるため、コンテナーのホスト名も webapp01と名付けられています。

Windows Server 2019 以降では、ホスト名フィールドは必要ありませんが、明示的に別のものを指定した場合でも、コンテナーはホスト名ではなく gMSA 名で自身を識別します。

gMSA が正常に動作しているかどうかを確認するには、コンテナーで次のコマンドレットを実行します。

# Replace contoso.com with your own domain
PS C:\> nltest /sc_verify:contoso.com

Flags: b0 HAS_IP  HAS_TIMESERV
Trusted DC Name \\dc01.contoso.com
Trusted DC Connection Status Status = 0 0x0 NERR_Success
Trust Verification Status = 0 0x0 NERR_Success
The command completed successfully

[信頼された DC 接続の状態] と [信頼の確認の状態] が NERR_Successされていない場合は、 トラブルシューティングの手順に従って問題をデバッグします。

次のコマンドを実行し、クライアント名を確認することで、コンテナー内から gMSA ID を確認できます。

PS C:\> klist get webapp01

Current LogonId is 0:0xaa79ef8
A ticket to krbtgt has been retrieved successfully.

Cached Tickets: (2)

#0>     Client: webapp01$ @ CONTOSO.COM
        Server: krbtgt/webapp01 @ CONTOSO.COM
        KerbTicket Encryption Type: AES-256-CTS-HMAC-SHA1-96
        Ticket Flags 0x40a10000 -> forwardable renewable pre_authent name_canonicalize
        Start Time: 3/21/2019 4:17:53 (local)
        End Time:   3/21/2019 14:17:53 (local)
        Renew Time: 3/28/2019 4:17:42 (local)
        Session Key Type: AES-256-CTS-HMAC-SHA1-96
        Cache Flags: 0
        Kdc Called: dc01.contoso.com

[...]

PowerShell または別のコンソール アプリを gMSA アカウントとして開くには、通常の ContainerAdministrator (または NanoServer 用 ContainerUser) アカウントではなく、ネットワーク サービス アカウントで実行するようにコンテナーに依頼できます。

# NOTE: you can only run as Network Service or SYSTEM on Windows Server 1709 and later
docker run --security-opt "credentialspec=file://contoso_webapp01.json" --hostname webapp01 --user "NT AUTHORITY\NETWORK SERVICE" -it mcr.microsoft.com/windows/servercore:ltsc2019 powershell

ネットワーク サービスとして実行している場合は、ドメイン コントローラーで SYSVOL に接続することで、gMSA としてのネットワーク認証をテストできます。

# This command should succeed if you're successfully running as the gMSA
PS C:\> dir \\contoso.com\SYSVOL


    Directory: \\contoso.com\sysvol


Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d----l        2/27/2019   8:09 PM                contoso.com

コンテナーの実行に加えて、gMSA を使用して次のことができます。

セットアップ中に問題が発生した場合は、トラブルシューティング ガイドの で考えられる解決策を確認してください。