*Win Docker(Windows2016TP4)にIISをインストール [#k27b3479]

RIGHT:更新日 &lastmod();

**Windows2016TP4 US版のインストール [#eaad240f]

日本語版はエラー(コンテナにIISをインストールできない)するので英語版をインストール。

&color(red){この時、地区もキーボードは101を選択のこと。};

Download

-https://www.microsoft.com/en-us/evalcenter/evaluate-windows-server-technical-preview

&ref("./Win-Docker-IIS0.png");

***IISをインストールするコンテナを作成 [#m3cb8d0d]

以降はすべて英語モードのPowerShaell (\→バックスラッシュ)

 PS C:\Windows\system32> $Container=New-Container -Name "IISC" \
 -ContainerImageName "WindowsServerCore" -SwitchName "Virtual Switch"

***コンテナを起動 [#m5bcc0ec]

 PS C:\Windows\system32> Start-Container -Name IISC

***コンテナにPowerShellセッションを接続 [#d8f883a0]

 PS C:\Windows\system32> $Container=Get-Container -Name IISC
 PS C:\Windows\system32> Enter-PSSession -ContainerId $Container.ContainerId -RunAsAdministrator

コンテナにIISをインストール

 [IISC]: PS C:\Windows\system32> Install-WindowsFeature Web-Server
 
 Success Restart Needed Exit Code      Feature Result
 ------- -------------- ---------      --------------
 True    No             Success        {Common HTTP Features, Defaul...

&ref("./Win-Docker-IIS1.png");

***PowerShellのセッションの接続を閉じて、コンテナを停止 [#m1d0bef1]

 [IISC]: PS C:\Windows\system32> EXIT
 PS C:\Windows\system32> Stop-Container $Container
 PS C:\Windows\system32> New-ContainerImage -ContainerName $container.Name -Publisher "JE2ISM" -Name "IISCImage" -Version 1.0
 
 Name      Publisher Version IsOSImage
 ----      --------- ------- ---------
 IISCImage CN=JE2ISM 1.0.0.0 False

IISをインストールしたコンテナをコンテナイメージとして保存しておくことで、何度でもコピーして使い回すことができる

作成したコンテナイメージをエクスポートしてAPPXファイルとし、他のコンテナホストにインポートすることで、コンテナイメージを配布するできる

''エクスポート''

 PS C:\Windows\system32> $image = Get-ContainerImage -Name "IISCImage"
 PS C:\Windows\system32> Export-ContainerImage -Image $image -Path "C:\DockerImages"
 
 PS C:\Windows\system32> dir C:\DockerImges\
 
 
     Directory: C:\DockerImges
 
 
 Mode                LastWriteTime         Length Name
 ----                -------------         ------ ----
 -a----        3/20/2016   5:26 PM      169458212 CN=JE2ISM_IISCImage_1.0.0.0.APPX

''インポート''

 PS C:\Windows\system32> Import-ContainerImage -Path "C:\DockerImages\CN=JE2ISM_IISCImage_1.0.0.0.APPX"
 
 Name      Publisher Version IsOSImage
 ----      --------- ------- ---------
 IISCImage CN=JE2ISM 1.0.0.0 False

***IISコンテナの公開'' [#ffe8fbf2]

基本ポートフォーワード

''NetWorkの確認''

 [IISC]: PS C:\Windows\system32> ipconfig
 
 Windows IP Configuration 
 
 
 Ethernet adapter vEthernet (Virtual Switch-37FF57D3-DB68-4719-97D7-32507F1F2AD4-0):
 
    Connection-specific DNS Suffix  . : flets-west.jp
    Link-local IPv6 Address . . . . . : fe80::4d10:4fe6:7569:505e%17
    IPv4 Address. . . . . . . . . . . : 172.16.0.2
    Subnet Mask . . . . . . . . . . . : 255.240.0.0
    Default Gateway . . . . . . . . . : 172.16.0.1

''NATの確認''

 [IISC]: PS C:\Windows\system32> Get-NetNat
  
 
 Name                             : ContainerNAT
 ExternalIPInterfaceAddressPrefix :
 InternalIPInterfaceAddressPrefix : 172.16.0.0/12
 IcmpQueryTimeout                 : 30
 TcpEstablishedConnectionTimeout  : 1800
 TcpTransientConnectionTimeout    : 120
 TcpFilteringBehavior             : AddressDependentFiltering
 UdpFilteringBehavior             : AddressDependentFiltering
 UdpIdleSessionTimeout            : 120
 UdpInboundRefresh                : False
 Store                            : Local
 Active                           : True




-NatName:NAT名
-Protocol :HTTPの公開なのでTCP
-ExternalIPAddress:0.0.0.0(アクセス許可IP)
-InternalIPAddress:IISコンテナのIPアドレス
-InternalPort:コンテナのWebサイトのポート番号 
-ExternalPort :公開するポート番号


''ポートフォーワードの設定''

 [IISC]: PS C:\> Add-NetNatStaticMapping -NatName "ContainerNAT" -Protocol \
 C:\> Add-NetNatStaticMapping -NatName "ContainerNAT" -Protocol \
 TCP -ExternalIPAddress 0.0.0.0 -InternalIPAddress 172.16.0.2 \
 -InternalPort 80 -ExternalPort 80
 
 
 StaticMappingID               : 0
 NatName                       : ContainerNAT
 Protocol                      : TCP
 RemoteExternalIPAddressPrefix : 0.0.0.0/0
 ExternalIPAddress             : 0.0.0.0
 ExternalPort                  : 80
 InternalIPAddress             : 172.16.0.2
 InternalPort                  : 80
 InternalRoutingDomainId       : {00000000-0000-0000-0000-000000000000}
 Active                        : True


''コンテナホストのファイアウォールのTCP80番ポートを開く''

GUIの「Windowsファイアウォール」でも設定可能

ホスト側で

 PS C:\> if (!(Get-NetFirewallRule | where {$_.Name -eq "TCP80"})) \
 {New-NetFirewallRule -Name "TCP80" -DisplayName "HTTPon TCP/80" \
 -Protocol tcp -LocalPort 80 -Action Allow -Enabled True}
 
 
 Name                  : TCP80
 DisplayName           : HTTP on TCP/80
 Description           :
 DisplayGroup          :
 Group                 :
 Enabled               : True
 Profile               : Any
 Platform              : {}
 Direction             : Inbound
 Action                : Allow
 EdgeTraversalPolicy   : Block
 LooseSourceMapping    : False
 LocalOnlyMapping      : False
 Owner                 :
 PrimaryStatus         : OK
 Status                : The rule was parsed successfully from the store. (65536) 
 EnforcementStatus     : NotApplicable
 PolicyStoreSource     : PersistentStore
 PolicyStoreSourceType : Local

&ref("./Win-Docker-IIS2.png");

***確認 [#q4204d63]

-ファイアウォールのGUIで確認

&ref("./Win-Docker-IIS3.png");

**NATの接続確認 [#l8a14a31]

 [IISC]: PS C:\Windows\system32> Get-NetNatSession
 
 
 NatName                    : ContainerNAT
 InternalRoutingDomainId    : {b1062982-2b18-4b4f-b3d5-a78ddb9cdd49}
 CreationTime               : 3/20/2016 5:55:18 PM
 Protocol                   : 6
 InternalSourceAddress      : 172.16.0.2
 InternalSourcePort         : 80
 InternalDestinationAddress : 192.168.10.47
 InternalDestinationPort    : 56573
 ExternalSourceAddress      : 192.168.10.93
 ExternalSourcePort         : 80
 ExternalDestinationAddress : 192.168.10.47
 ExternalDestinationPort    : 56573

**参考 [#y6bae107]

https://www.gmo.jp/report/single/?art_id=200



トップ   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS