*Windows Server 2016 Technical Preview 4(TP4)でWindows Server Containers [#ub8d4eb5] RIGHT:更新日 &lastmod(); Windows Server上でDockerと同じようにアプリケーションを「コンテナ」にパッケージングして、デプロイ、実行できるようになったので、試してみる。 ''利用イメージ'' ------------------------ コンテナ作成 ------------------------ |WindowsServerCore |--------------→|コンテナ | | (コンテナイイメージ) | |(アプリをインストール)| ------------------------ ------------------------ | |コンテナイメージ作成 | ---------------------------- |アプリ入りコンテナイメージ| ---------------------------- | | ----------------------- ---------------------------- |アプリを追加し | | リポジトリとして保管 | | コンテナを利用 | コンテナ作成 | | | | ←----------------| | ----------------------- ---------------------------- リポジトリとあるコンテナイメージから派生していろんなアプリを追加 したコンテナができる(共通アプリをインストールした時点でイメージ化して リポジトリに保管しておく) ***Install [#g0e750a6] -サーバの機能にContainersを追加 &ref("./Win-Docker1.png"); -サービス、ネットワークアダプタの確認 &ref("./Win-Docker3.png"); ***コンテナイメージやセットアップスクリプトをダウンロード [#r57954e1] &color(red){''PowerShellを管理者権限で実行''}; cd \ PS C:\> wget -uri https://aka.ms/tp4/Install-ContainerHost -OutFile C:\Install-ContainerHost.ps1 PS C:\ .\Install-ContainerHost.ps1 Querying status of Windows feature: Containers... Feature Containers is already enabled. Waiting for Hyper-V Management... Enabling container networking... Creating container switch (NAT)... Creating NAT for 172.16.0.0/12... Installing ContainerProvider package... Getting Container OS image (WindowsServerCore) version 10.0.10586.0 from OneGet\ (this may take a few minutes)... (1時間以上DLにかかる) ←ここで[Enter]が必要なときもある Container base image install complete. Querying container images... The following images are present on this machine: ContainerImage (Name = 'WindowsServerCore') [Publisher = 'CN=Microsoft', Version = '10.0.10586.0'] Installing Docker... Creating Docker program data... This script uses a third party tool: NSSM. For more information, see https://nssm.cc/usage Downloading NSSM... Extracting NSSM from archive... Configuring NSSM for Docker service... Waiting for Docker daemon... Successfully connected to Docker Daemon. Tagging new base image (6801d964fda5)... Base image is now tagged: windowsservercore 10.0.10586.0 6801d964fda5 8 weeks ago 0 B windowsservercore latest 6801d964fda5 8 weeks ago 0 B Script complete! コンテナOSイメージが「C:\ProgramData\Microsoft\Windows\Images」 に入る。 &ref("./Win-Docker4.png"); Docker Daemonのインストールも行われる。 &ref("./Win-Docker2.png"); ''コンテナ関係のコマンド'' PS C:\> Get-Command -Module Containers CommandType Name Version S ource ----------- ---- ------- ------ Function Install-ContainerOSImage 1.0.0.0 Containers Function Uninstall-ContainerOSImage 1.0.0.0 Containers Cmdlet Add-ContainerNetworkAdapter 1.0.0.0 Containers Cmdlet Add-ContainerSharedFolder 1.0.0.0 Containers Cmdlet Connect-ContainerNetworkAdapter 1.0.0.0 Containers Cmdlet Disconnect-ContainerNetworkAdapter 1.0.0.0 Containers Cmdlet Export-ContainerImage 1.0.0.0 Containers Cmdlet Get-Container 1.0.0.0 Containers Cmdlet Get-ContainerHost 1.0.0.0 Containers Cmdlet Get-ContainerImage 1.0.0.0 Containers Cmdlet Get-ContainerMemory 1.0.0.0 Containers Cmdlet Get-ContainerNetworkAdapter 1.0.0.0 Containers Cmdlet Get-ContainerProcessor 1.0.0.0 Containers Cmdlet Get-ContainerSharedFolder 1.0.0.0 Containers Cmdlet Get-ContainerStorage 1.0.0.0 Containers Cmdlet Import-ContainerImage 1.0.0.0 Containers Cmdlet Move-ContainerImageRepository 1.0.0.0 Containers Cmdlet New-Container 1.0.0.0 Containers Cmdlet New-ContainerImage 1.0.0.0 Containers Cmdlet Remove-Container 1.0.0.0 Containers Cmdlet Remove-ContainerImage 1.0.0.0 Containers Cmdlet Remove-ContainerNetworkAdapter 1.0.0.0 Containers Cmdlet Remove-ContainerSharedFolder 1.0.0.0 Containers Cmdlet Set-Container 1.0.0.0 Containers Cmdlet Set-ContainerMemory 1.0.0.0 Containers Cmdlet Set-ContainerNetworkAdapter 1.0.0.0 Containers Cmdlet Set-ContainerProcessor 1.0.0.0 Containers Cmdlet Set-ContainerSharedFolder 1.0.0.0 Containers Cmdlet Set-ContainerStorage 1.0.0.0 Containers Cmdlet Start-Container 1.0.0.0 Containers Cmdlet Stop-Container 1.0.0.0 Containers Cmdlet Test-ContainerImage 1.0.0.0 Containers &color(red){TP5までは上ののコマンドが利用出来るが、Windows正式版からは変更される}; -https://docs.microsoft.com/ja-jp/virtualization/windowscontainers/management/docker-powershell -理由 : https://docs.microsoft.com/ja-jp/virtualization/windowscontainers/management/docker-powershell 正式版は3つしかない(2017/3) PS C:\Windows\system32> Get-Command -Module Containers CommandType Name Version Source ----------- ---- ------- ------ Cmdlet Get-ContainerNetwork 1.0.0.0 Containers Cmdlet New-ContainerNetwork 1.0.0.0 Containers Cmdlet Remove-ContainerNetwork 1.0.0.0 Containers ''Windowsのコンテナイメージの確認'' PS C:\> Get-ContainerImage Name Publisher Version IsOSImage ---- --------- ------- --------- WindowsServerCore CN=Microsoft 10.0.10586.0 True ''コンテナ作成'' PS C:\> New-Container -Name "IsmContainer" -ContainerImageName "WindowsServerCore" -SwitchName "Virtual Switch" Name State Uptime ParentImageName ---- ----- ------ --------------- IsmContainer Off 00:00:00 WindowsServerCore -Name:コンテナ名 -ContainerImageName:テンプレートとなるコンテナイメージ -SwitchName:コンテナが接続する仮想スイッチ、"Get-VMSwitch" で確認 ''コンテナの確認'' PS C:\> Get-Container Name State Uptime ParentImageName ---- ----- ------ --------------- IsmContainer Off 00:00:00 WindowsServerCore ''SWの確認'' PS C:\> Get-VMSwitch Name SwitchType NetAdapterInterfaceDescription ---- ---------- ------------------------------ Virtual Switch NAT ''コンテナの起動'' PS C:\> Start-Container -Name IsmContainer PS C:\> Get-Container Name State Uptime ParentImageName ---- ----- ------ --------------- IsmContainer Running 00:00:07.0770000 WindowsServerCore ^^^^^^^ Off→ Runnig ***起動したコンテナを管理するには、PowerShellをリモートから実行する [#v2121d2f] ''コンテナに入る'' PS C:\> $Container = Get-Container -Name "IsmContainer" PS C:\> Enter-PSSession -ContainerId $Container.ContainerId -RunAsAdministrator [IsmContainer]: PS C:\Windows\system32> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^コンテナ内のshell [IsmContainer]: PS C:\Windows\system32> ping 192.168.10.245 Pinging 192.168.10.245 with 32 bytes of data: Reply from 192.168.10.245: bytes=32 time<1ms TTL=63 Reply from 192.168.10.245: bytes=32 time<1ms TTL=63 [IsmContainer]: PS C:\Windows\system32> tracert 192.168.10.245 Tracing route to bhr-4grv.ism21.net [192.168.10.245] over a maximum of 30 hops: 1 * * * Request timed out. 2 <1 ms <1 ms <1 ms bhr-4grv.ism21.net [192.168.10.245] [IsmContainer]: PS C:\Windows\system32> ping www.google.co.jp Pinging www.google.co.jp [216.58.221.163] with 32 bytes of data: Reply from 216.58.221.163: bytes=32 time=19ms TTL=55 Reply from 216.58.221.163: bytes=32 time=18ms TTL=55 ''コンテナから出る'' [IsmContainer]: PS C:\Windows\system32> exit PS C:\> ''コンテナのShutdown'' PS C:\> Stop-Container -Name IsmContainer PS C:\> Get-Container Name State Uptime ParentImageName ---- ----- ------ --------------- IsmContainer Off 00:00:00 WindowsServerCore ^^^ ''コンテナの削除'' > Get-Container -Name "IISContainer" | Remove-Container -Force **参考 [#dd832411] -http://codename2010.blog11.fc2.com/blog-entry-268.html -https://www.gmo.jp/report/single/?art_id=200