Windows2016Server(Standard)コンテナ(Hyper-Vコンテナ・indows Serverコンテナ †更新日 2018-02-25 (日) 08:32:00
Windows Server 2016にはWindows ServerコンテナとHyper-Vコンテナの2種類がある。 特徴は以下のURL Windowsコンテナのインストール †WindowsをUpdateしておく Hyper-Vの役割Installと再起動 †
PowerShellを管理者で起動 PS C:\Users\JE2ISM> Install-WindowsFeature hyper-v Success Restart Needed Exit Code Feature Result ------- -------------- --------- -------------- True Yes SuccessRest... {Hyper-V} 警告: インストール処理を完了するには、このサーバーを再起動する必要があります。
Docker機能のインストール †
PS C:\Users\JE2ISM> Install-Module -Name DockerMsftProvider -Repository PSGallery -Force 続行するには NuGet プロバイダーが必要です PowerShellGet で NuGet ベースのリポジトリを操作するには、'2.8.5.201' 以降のバージョンの NuGet プロバイダーが必要です。NuGet プロバイダーは 'C:\Program Files\PackageManagement\ProviderAssemblies' または 'C:\Users\JE2ISM\AppData\Local\PackageManagement\ProviderAssemblies' に配置する必要があります。'Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force' を実行して NuGet プロバイダーをインストールすることもできます。今すぐ PowerShellGet で NuGet プロバイダーをインストールしてインポートしますか? [Y] はい(Y) [N] いいえ(N) [S] 中断(S) [?] ヘルプ (既定値は "Y"):Y ←入力
PS C:\Users\JE2ISM> Install-Package -Name docker -ProviderName DockerMsftProvider パッケージは、信頼済みとマークされていないパッケージ ソースから取得されています。 'DockerDefault' からソフトウェアをアンインストールしますか? [Y] はい(Y) [A] すべて続行(A) [N] いいえ(N) [L] すべて無視(L) [S] 中断(S) [?] ヘルプ (既定値は "N"):A ←入力 警告: A restart is required to start docker service. Please restart your machine. 警告: After the restart please start the docker service. Name Version Source Summary ---- ------- ------ ------- Docker 1.13.1 DockerDefault Contains the CS Docker Engine for use with Windows ...
PS C:\Users\JE2ISM> Restart-Computer -Force
PS C:\Users\JE2ISM> sconfig =============================================================================== サーバー構成 =============================================================================== 1) ドメイン/ワークグループ: ドメイン: vmw.ism21.net 2) コンピューター名: WIN2016STD 3) ローカル管理者の追加 4) リモート管理の構成 有効 5) Windows Update の設定: ダウンロードのみ 6) 更新プログラムのダウンロードとインストール 7) リモート デスクトップ: 有効 (より安全なクライアントのみ) 8) ネットワーク設定 9) 日付と時刻 10) 製品利用統計情報の設定 基本 11) Windows ライセンス認証 12) ユーザーのログオフ 13) サーバーの再起動 14) サーバーのシャットダウン 15) 終了してコマンド ラインに戻る 選択するオプションの番号を入力してください: 6 すべての更新プログラム (A) を検索するか、推奨される更新プログラムのみ (R) を検索するかを選択してください。A すべての適用可能な更新プログラムを検索しています... このコンピューターに対して適用できる項目を表示します: 1> Windows Defender の定義の更新 ? KB2267602 (定義 1.237.219.0) オプションを選択してください: すべての更新プログラムをインストールする (A)、更新プログラムをインストールしない (N)、または単一の更新プログラムを選択する (S) から選択してください。A 更新プログラムをダウンロードしています... 更新プログラムをインストールしています... インストールされた更新プログラムの一覧と、それぞれのインストール結果を表示します: 1> Windows Defender の定義の更新 ? KB2267602 (定義 1.237.219.0): 成功 インストール結果: 成功 次の項目の再起動が必要です: False Windowsコンテナの動作確認 †
PS C:\Users\JE2ISM> docker version Client: Version: 1.13.1-cs1 API version: 1.26 Go version: go1.7.5 Git commit: 8709b81 Built: Thu Feb 9 02:05:36 2017 OS/Arch: windows/amd64 Server: Version: 1.13.1-cs1 API version: 1.26 (minimum version 1.24) Go version: go1.7.5 Git commit: 8709b81 Built: Thu Feb 9 02:05:36 2017 OS/Arch: windows/amd64 Experimental: false
PS C:\Windows\system32> docker info Containers: 0 Running: 0 Paused: 0 Stopped: 0 Images: 0 Server Version: 1.13.1-cs1 Storage Driver: windowsfilter Windows: Logging Driver: json-file Plugins: Volume: local Network: l2bridge l2tunnel nat null overlay transparent Swarm: inactive Default Isolation: process Kernel Version: 10.0 14393 (14393.693.amd64fre.rs1_release.161220-1747) Operating System: Windows Server 2016 Standard Evaluation OSType: windows Architecture: x86_64 CPUs: 8 Total Memory: 17.99 GiB Name: win2016std ID: VW6B:E3LD:UVDW:PZK5:SOXV:J4TW:OMOC:AQE4:CEDS:RH3O:MS4B:WQEK Docker Root Dir: C:\ProgramData\docker Debug Mode (client): false Debug Mode (server): false Registry: https://index.docker.io/v1/ Experimental: false Insecure Registries: 127.0.0.0/8 Live Restore Enabled: false
PS C:\Windows\system32> docker run microsoft/dotnet-samples:dotnetapp-nanoserver Unable to find image 'microsoft/dotnet-samples:dotnetapp-nanoserver' locally dotnetapp-nanoserver: Pulling from microsoft/dotnet-samples bce2fbc256ea: Pull complete 3ac17e2e6106: Pull complete 4638f7412695: Pull complete a7926e7b6a22: Pull complete 0e1e856c5213: Pull complete 81c5e180fe78: Pull complete 426ea0b0913e: Pull complete 6c1061014a6f: Pull complete 25a363e83ca4: Pull complete 42f0eebe97a1: Pull complete Digest: sha256:9422dc99fedc002a651eb77c4566d44dc6ed821b2ea15b1fcaa12a97fba1f4ab Status: Downloaded newer image for microsoft/dotnet-samples:dotnetapp-nanoserver Dotnet-bot: Welcome to using .NET Core! __________________ \ \ .... ....' .... .......... .............'..'.. ................'..'..... .......'..........'..'..'.... ........'..........'..'..'..... .'....'..'..........'..'.......'. .'..................'... ...... . ......'......... ..... . ...... .. . .. ...... .... . ....... ...... ....... ............ ................ ...................... ........................'................ ......................'..'...... ....... .........................'..'..... ....... ........ ..'.............'..'.... .......... ..'..'... ...............'....... .......... ...'...... ...... .......... ...... ....... ........... ....... ........ ...... ....... '...'.'. '.'.'.' .... ....... .....'.. ..'..... .. .......... ..'........ ............ .............. ............. '.............. ...........'.. .'.'............ ............... .'.'............. .............'.. ..'..'........... ............... .'.............. ......... .............. ..... **Environment** Platform: .NET Core 1.0 OS: Microsoft Windows 10.0.14393
PS C:\Windows\system32> docker images REPOSITORY TAG IMAGE ID CREATED SIZE microsoft/dotnet-samples dotnetapp-nanoserver 661dce9dd1fd 7 days ago 1.03 GB microsoft/nanoserver latest d9bccb9d4cac 7 weeks ago 925 MB Nano ServerをWindowsコンテナで起動して、コマンドプロンプトを開く †docker run を実行したら、コンテナのプロセスを隔離(独立)して実行する。コンテナは自身ファイルシステムとネットワークを持ち、ホスト上の他のプロセス・ツリーからは隔離されて(独立して)いる。 PS C:\Windows\system32> docker run -it microsoft/nanoserver cmd Microsoft Windows [Version 10.0.14393] (c) 2016 Microsoft Corporation. All rights reserved. C:\> C:\>dir Volume in drive C has no label. 英語版になっている Volume Serial Number is 36EF-3414 Directory of C:\ 11/20/2016 08:32 PM 1,894 License.txt 07/16/2016 09:20 PM <DIR> Program Files 07/16/2016 09:09 PM <DIR> Program Files (x86) 02/26/2017 08:19 PM <DIR> Users 02/26/2017 08:19 PM <DIR> Windows 1 File(s) 1,894 bytes 4 Dir(s) 21,244,018,688 bytes free C:\> exit ← コンテナから出る
docker run -it ← docker run -i -t (シェルのような)インタラクティブなプロセスでは、コンテナのプロセスに対して ttyを割り当てるために、 -i -t を一緒に使う必要がある Hyper-Vコンテナとして実行してみる †起動に時間かかる Enterがいるかも PS C:\Windows\system32> docker run --isolation hyperv -it microsoft/nanoserver cmd Microsoft Windows [Version 10.0.14393] (c) 2016 Microsoft Corporation. All rights reserved. C:\>
PS C:\Windows\system32> docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES e79ff2ef7bf6 microsoft/nanoserver "cmd" 3 minutes ago Up 2 minutes friendly_engelbart
PS C:\Windows\system32> docker stop e79ff2ef7bf6 e79ff2ef7bf6
C:\>powershell Windows PowerShell Copyright (C) 2016 Microsoft Corporation. All rights reserved. PS C:\>
PS C:\> Get-ComputerInfo WindowsBuildLabEx : 14393.0.amd64fre.rs1_ release.160715-1616 WindowsCurrentVersion : 6.3 WindowsEditionId : ServerDatacenterNano WindowsInstallationType : Nano Server WindowsInstallDateFromRegistry : 3/3/2017 7:57:30 PM WindowsProductId : WindowsProductName : Windows Server 2016 Datacenter WindowsRegisteredOrganization : WindowsRegisteredOwner : (省略)
PS C:\Windows\system32> docker search bash NAME DESCRIPTION STARS OFFICIAL AUTOMATED bash Bash is the GNU Project's Bourne Again SHell 19 [OK] bashell/alpine-bash Alpine Linux with /bin/bash as a default s... 12 [OK] frolvlad/alpine-bash Docker image with Bash and complete utils ... 5 [OK] buchireddy/docker-bash Docker in docker with bash shell installed. 1 [OK] tavisto/alpine-bash Alpine Linux Docker image that just contai... 1 [OK] (略) PS C:\Windows\system32> docker search microsoft/* NAME DESCRIPTION STARS OFFICIAL AUTOMAT D microsoft/aspnet ASP.NET is an open source server-side Web ... 561 [OK] microsoft/dotnet Official images for .NET Core for Lin ux an... 454 [OK] mono Mono is an open source implementation of M... 219 [OK] microsoft/mssql-server-linux Official images for Microsoft SQL Server o... 182 microsoft/nanoserver Windows Server 2016 Nano Server base OS im... 141 (略)
PS C:\Windows\system32> docker pull bash Using default tag: latest latest: Pulling from library/bash image operating system "linux" cannot be used on this platform 「docker version」で確認すると Server: OS/Arch: linux/amd64 ではないのでLinuxはNG どのようにしてlinuxを入れるのか現在不明 コンテナのLAN †以下の「vEthernet (HNS Internal NIC)」が有効時に「Hyper-Vコンテナ」「Windowsコンテナ」のどちらもが外部と接続できる。無効だと外部と接続できない
DockerでIISをインストール †
PS C:\Windows\system32> docker pull microsoft/iis Using default tag: latest latest: Pulling from microsoft/iis 3889bb8d808b: Already exists 3430754e4d17: Already exists 7aee39cd34f9: Pull complete 5b8e6b632025: Pull complete e067d71858d2: Pull complete Digest: sha256:a9a3e01f2dd9273a57317acc3c163f2f765e40397f0d304339dedf4bfd10c32d Status: Downloaded newer image for microsoft/iis:latest PS C:\Windows\system32> docker images REPOSITORY TAG IMAGE ID CREATED SIZE microsoft/dotnet-samples dotnetapp-nanoserver 661dce9dd1fd 8 days ago 1.03 GB microsoft/iis latest a3dd2dff392b 7 weeks ago 9.82 GB microsoft/windowsservercore latest 4d83c32ad497 7 weeks ago 9.56 GB microsoft/nanoserver latest d9bccb9d4cac 7 weeks ago 925 MB DockerのIIS起動 †
PS C:\Windows\system32> docker run -d -p 80:80 microsoft/iis f3dd485b6a4ff243aeda49c4abba2e70f4dfd8350259fc076749f0df4433fa5b PS C:\Windows\system32> PS C:\Windows\system32> docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES f3dd485b6a4f microsoft/iis "C:\\ServiceMonitor..." 44 seconds ago Up 35 seconds 0.0.0.0:80->80 /tcp youthful_hugle 0.0.0.0:80->80でポートフォワードが確認できる
docker exec は実行中のコンテナに入る PS C:\Windows\system32> docker exec -i -t f3dd485b6a4f cmd コマンド (docker exec -i -t CONTAINER_ID cmd)
HostPCからまたは他のPCからは http://192.168.10.94/ ← Windows2016ホストIP IIS 2つを起動 †PS C:\Windows\system32> docker run -d -p 8080:80 microsoft/iis PS C:\Windows\system32> docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 15eb1c521328 microsoft/iis "C:\\ServiceMonitor..." 19 seconds ago Up 10 seconds 0.0.0.0:8080-> 80/tcp happy_boyd f1ef7f4ec8e4 microsoft/iis "C:\\ServiceMonitor..." 4 minutes ago Up 4 minutes 0.0.0.0:80->80/tcp quirky_raman 参考 † |