SlideShare a Scribd company logo
Windows Server 2016上で
Linuxコンテナが動いた!
2017年10月14日
System Center User Group Japan
金井 崇
自己紹介
• 名前:金井 崇
• 所属:株式会社IDCフロンティア
• 仕事:IaaSの基盤設計・構築・運用・提案を担当
• 興味:仮想化 コンテナ オールフラッシュ GPU FPGA
Chef Docker PowerShell VSCode Hadoop
• MVP:Cloud and Data Center Management (2017/03~)
• SNSなど:
• Facebook https://www.facebook.com/anikundesu
• Blog http://www.takanyan.net/
• Twitter @anikundesu
• LinkedIn https://jp.linkedin.com/in/takashikanai/ja
• SlideShare https://www.slideshare.net/anikundesu/presentations
2Copyright © 2017 System Center User Group Japan. All Rights Reserved.
注意事項
本セッションは、Windows Server Insider Preview 16278での検証結果をもとに記述をしています。
正式版では挙動が異なる場合がありますので、ご留意ください。
本セッション資料は、個人で準備した環境において、個人的に実施した検証・結果を基に記載して
います。あくまで個人の意見・見解であり、所属する会社・組織及びマイクロソフト社とは関係が
ございません。所属する会社・組織・マイクロソフト社の正式な回答・見解ではない事に留意して
ください。
本資料を閲覧した事により問題が生じた場合、または問題が発生しかけた場合、または生じた一切
の不利益について、発表者は一切の責任を負う事はできませんのでご了承ください。
3Copyright © 2017 System Center User Group Japan. All Rights Reserved.
本日のアジェンダ
Windows Server上でLinuxカーネルベースの
コンテナが動く仕組み2
Hyper-V仮想マシン上のWindows Serverで
Linuxカーネルベースのコンテナを動かすデモ3
まとめ4
Windows Server Semi-Annual Release 1709の
コンテナ向け新機能紹介1
4Copyright © 2017 System Center User Group Japan. All Rights Reserved.
Windows Server Semi-Annual Release
1709のコンテナ向け新機能紹介
Section 1
5Copyright © 2017 System Center User Group Japan. All Rights Reserved.
Semi-Annualu Release 1709の新機能
<コンテナ関連でアナウンスされた新機能>
1. 新しいコンテナベースイメージ
– Nano Server:70%以上縮小され80MBに
– Server Core :20%以上縮小
2. コンテナがSMBボリュームのマウントをサポート
3. コンテナオーケストレーター向け基盤
– KubernetesクラスターでLinuxと同等のネットワーク機能をサポート
– Named pipe mapping対応
<正式アナウンスされていない新機能>
4. Hyper-Vコンテナー+LinuxKITでLinuxカーネルベースのコンテナに対応
6Copyright © 2017 System Center User Group Japan. All Rights Reserved.
Nano Serverはコンテナー専用
• Nano Serverは.NET Coreアプリケーションの動作に最適化
• PowerShell、.NET Core、WMIはデフォルト非搭載
– ユーザーが自分のコンテナーイメージを作る際にPowerShell
や.NET Coreコンテナパッケージを追加することは可能
• アップデートはDockerHub経由で新しいイメージを配布
• Nano ServerのトラブルシュートはDockerを使う
– “docker run (イメージ名) –ti cmd”など
• Windows IoT Core上でNano Serverのコンテナが起動可能
• Nano ServerのVMイメージは廃止
7Copyright © 2017 System Center User Group Japan. All Rights Reserved.
出典:Changes to Nano Server in the next release of Windows Server
https://docs.microsoft.com/en-us/windows-server/get-started/nano-in-semi-annual-channel
Kubernetes対応することの意味
• Kubernetesはコンテナオーケスト
レーターの(ほぼ)標準
• コンテナクラスタを作るために必要
なSDNもLinux Kernelの機能で実装
• WindowsはこのSDN実装に対応
KubernetesクラスタをWindowsだけで
作れるようになる
8Copyright © 2017 System Center User Group Japan. All Rights Reserved.
出典:Windows Networking at Parity with Linux for Kubernetes
https://www.cncf.io/blog/2017/09/08/windows-networking-parity-linux-kubernetes/
Windows Server 1709での
Kubernetes Network機能対応
Windows Server上でLinuxカーネル
ベースのコンテナが動く仕組み
Section 2
9Copyright © 2017 System Center User Group Japan. All Rights Reserved.
Linuxカーネルが動く仕組みの概要
1. 基本はHyper-Vコンテナー
2. Hyper-VゲストOSはLinuxKit(極小Linux)
3. WSL(Windows Subsystem for Linux)は使ってい
ない!
10Copyright © 2017 System Center User Group Japan. All Rights Reserved.
【復習】Hyper-Vコンテナー
• 一つのコンテナに1つのOS
• Docker APIでHyper-Vの仮想環境を操作
11
Windowsホスト
OS Kernel VM1 VM2
Process1 Process2
Docker Engine
ホスト
Process
Docker Client
Docker API
Hyper-V
ゲスト1
Win Kernel
ゲスト2
Win Kernel
Copyright © 2017 System Center User Group Japan. All Rights Reserved.
Hyper-Vコンテナー上のLinuxKit
• 一つのコンテナに1つのLinuxKIT OS
• Docker APIでHyper-Vの仮想環境を操作
12
Windowsホスト
OS Kernel VM1 VM2
Docker Engine
ホスト
Process
Docker Client
Docker API
Hyper-V
ゲスト1 ゲスト2
Copyright © 2017 System Center User Group Japan. All Rights Reserved.
Process1 Process2
LinuxKITの実体
• LinuxKITはコンテナを起動させるために最低限必要なLinux
• Hyper-V仮想マシン起動に必要なEFIファームウェアとLinuxメモリイメー
ジのみで構成
• dockerでコンテナ作成の命令が来るとこれらのファイルで自動的に
UtilityVMというものが作られ、その中でLinuxコンテナが起動される。
13Copyright © 2017 System Center User Group Japan. All Rights Reserved.
PS C:¥Program Files¥Linux Containers> ls
Directory: C:¥Program Files¥Linux Containers
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 2017/09/07 11:59 6845200 bootx64.efi
-a---- 2017/09/07 11:59 7235724 initrd.img
Docker for Windowsとの違い
• Hyper-V上にLinux仮想マシンを1つ作成(MobyLinuxVM)
• Docker APIでLinux仮想マシン上のコンテナを操作
14
Windowsホスト
OS Kernel VM
Docker Engine
ホスト
Process
Docker Client
Docker API
Hyper-V
Linux Kernel (MobyLinuxVM)
Linuxコンテナ
Process1
Linuxコンテナ
Process2
Copyright © 2017 System Center User Group Japan. All Rights Reserved.
Hyper-V仮想マシン上のWindows
ServerでLinuxカーネルベースのコン
テナを動かすデモ
Section 3
15Copyright © 2017 System Center User Group Japan. All Rights Reserved.
Hyper-V
デモでやりたかったこと
• ホストOSをWindows Server Insider Preview build 16278
• Hyper-VコンテナーでLinuxKIT動作を「見せたい」
16
Windows Server
Insider 16278
OS Kernel VM1 VM2
Docker Engine
ホスト
Process
Docker Client
Docker API
ゲスト1 ゲスト2
Copyright © 2017 System Center User Group Japan. All Rights Reserved.
Process1 Process2
Semi-Annual Releaseの特徴
Desktopエクスペリエンスなし!
デモを「見せられない」
17Copyright © 2017 System Center User Group Japan. All Rights Reserved.
出典:Windows Server の半期チャネルの概要
https://docs.microsoft.com/ja-jp/windows-server/get-started/semi-annual-channel-overview
インストール オプション
半期チャネル
(Windows Server)
Long-term Servicing チャネル
(Windows Server 2016)
Nano Server 〇 ×
Server Core 〇 〇
デスクトップ搭載サーバー × 〇
Hyper-V(親)
Windows Server
2016
(Win2k16host) Nested Hyper-V (VM名:Win2016-build16278)
本日のデモ環境の構成
Nested Hyper-Vを使って1PCで実現
18
VM1 VM2
Docker Engine
ゲスト1 ゲスト2
Copyright © 2017 System Center User Group Japan. All Rights Reserved.
Process1 Process2
この
プレゼン
Windows Server
Insider 16278
(Win2016-Guest)
Docker Client
Docker API
Nested Hyper-V構築手順
1. Windows Server Insider用VM作成(OSはまだ不要)
2. NestedVMを有効にするScriptをダウンロード
https://github.com/MicrosoftDocs/Virtualization-
Documentation/blob/master/hyperv-tools/Nested/Enable-NestedVm.ps1
3. Scriptを1.の仮想マシン名を引数に指定して実行
19Copyright © 2017 System Center User Group Japan. All Rights Reserved.
PS D:¥> .¥Enable-NestedVm.ps1 【VM名】
This script will set the following for 【VM名】 in order to enable nesting:
Virtualization extensions will be enabled
Optionally enable mac address spoofing
Input Y to accept or N to cancel:Y
Mac Address Spoofing isn't enabled (nested guests won't have network).
Would you like to enable MAC address spoofing? (Y/N)Y
MACアドレスSpoofing
も有効にする
Windows Server Insider Previewセットアップ
1. Windows Insiderページから
ISOを入手
2. Nested VM上でServer Core
をインストール
3. インストール後、sconfigコ
マンドで初期設定
– ホスト名の設定
– IPアドレスなどNetwork設定
– Remote Desktop接続有効化
20Copyright © 2017 System Center User Group Japan. All Rights Reserved.
複数のPowerShellセッションを使う準備
Enter-PSSessionコマンドレットを使ってリモートから
PowerShell実行ができるようにする
<接続先(Insider Preview)での設定>
<接続元クライアントでの設定>
21Copyright © 2017 System Center User Group Japan. All Rights Reserved.
C:¥> winrm quickconfig
PS C:¥> set-item WSMan:¥localhost¥Client¥TrustedHosts -Value 【接続先IP】
PS C:¥> Enter-PSSession -Computername 【接続先IP】 -Credential Administrator
Hyper-Vコンテナー構築手順
1. Hyper-VとContainer機能を有効化とOS再起動
2. Docker 17.06.0-ceのインストールとOS再起動
22Copyright © 2017 System Center User Group Japan. All Rights Reserved.
PS C:¥> Install-WindowsFeature Hyper-V,Containers –IncludeManagementTools
PS C:¥> Restart-Comptuer -Force
PS C:¥> Install-Module -Name DockerMsftProviderInsider -Repository PSGallery -Force
PS C:¥> Install-Package -Name docker -ProviderName DockerMsftProviderInsider -
RequiredVersion 17.06.0-ce
Docker CE 17.06を明示的に指定しないと、Linuxベースの
コンテナが動かないです。(2017年9月30日時点)
LinuxKITとDockerデーモン準備
1. LinuxKITのダウンロードと展開
2. Linuxコンテナ on Windows対応Dockerデーモン展開
23Copyright © 2017 System Center User Group Japan. All Rights Reserved.
PS C:¥> mkdir "$Env:ProgramFiles¥Linux Containers"
PS C:¥> Invoke-WebRequest -UseBasicParsing -OutFile linuxkit.zip
https://github.com/friism/linuxkit/releases/download/preview-1/linuxkit.zip
PS C:¥> Expand-Archive linuxkit.zip -DestinationPath "$Env:ProgramFiles¥Linux Containers¥.“
PS C:¥> rm linuxkit.zip
PS C:¥> mkdir “$Env:ProgramFiles¥lcow” ←dockerデーモンのインストールフォルダ作成
PS C:¥> cd "$Env:ProgramFiles¥lcow"
PS C:¥Program Files¥lcow¥> Invoke-WebRequest -UseBasicParsing -OutFile dockerd.exe
https://master.dockerproject.org/windows/x86_64/dockerd.exe
PS C:¥Program Files¥lcow¥> mkdir C:¥lcow ←コンテナイメージの保存フォルダを事前作成
DEMO:Linuxコンテナ on Windows
1. Linuxコンテナ起動用Dockerデーモンの起動
2. Linuxコンテナの起動
3. Windowsコンテナ起動用Dockerデーモンと比較
24Copyright © 2017 System Center User Group Japan. All Rights Reserved.
Linuxコンテナ起動用Dockerデーモンの起動
1. リモートからPowerShell接続してデーモン起動
2. RDPまたはローカルの「コマンドプロンプト」でLinux
カーネルベースのコンテナを起動
25Copyright © 2017 System Center User Group Japan. All Rights Reserved.
PS C:¥> Enter-PSSession -Computername 【接続先IP】 -Credential Administrator
[【接続先IP】 ]: PS C:¥Users¥Administrator¥Documents> cd "$Env:ProgramFiles¥lcow¥”
[【接続先IP】 ]: PS C:¥Program Files¥lcow> $Env:LCOW_SUPPORTED=1
[【接続先IP】 ]: PS C:¥Program Files¥lcow> .¥dockerd.exe -D --experimental -H
"npipe:////./pipe//docker_lcow" --data-root c:¥lcow
C:¥> docker -H "npipe:////./pipe//docker_lcow" run -ti busybox sh
/ # (←Linuxベースのコンテナでシェルが起動)
Windowsコンテナ起動用Dockerデーモンと比較
C:¥> docker -H "npipe:////./pipe//docker_lcow" version
Client:
Version: 17.06.0-ce
API version: 1.30
Go version: go1.8.3
Git commit: 02c1d87
Built: Fri Jun 23 21:30:30 2017
OS/Arch: windows/amd64
Server:
Version: master-dockerproject-2017-09-29
API version: 1.33 (minimum version 1.24)
Go version: go1.8.3
Git commit: ab2b03a
Built: Fri Sep 29 23:51:45 2017
OS/Arch: windows/amd64
Experimental: true
C:¥> docker version
Client:
Version: 17.06.0-ce
API version: 1.30
Go version: go1.8.3
Git commit: 02c1d87
Built: Fri Jun 23 21:30:30 2017
OS/Arch: windows/amd64
Server:
Version: 17.06.0-ce
API version: 1.30 (minimum version 1.24)
Go version: go1.8.3
Git commit: 02c1d87
Built: Fri Jun 23 22:19:00 2017
OS/Arch: windows/amd64
Experimental: false
26Copyright © 2017 System Center User Group Japan. All Rights Reserved.
LCOW対応版Dockerデーモン 通常のWindows用Dockerデーモン
まとめ
Section 4
27Copyright © 2017 System Center User Group Japan. All Rights Reserved.
まとめ
• Windows Server Semi-Annualu Release 1709はDesktop機能な
しでリリース。
• Windows ServerはWindowsだけではなくLinuxのコンテナにも対
応。オーケストレーターとしてKubernetesをサポートする。
• Linux Kernelベースのコンテナを実行するため、Hyper-Vコンテナ
でLinuxKIT(コンテナ実行用の極小Linux)を利用している。
28Copyright © 2017 System Center User Group Japan. All Rights Reserved.
参考資料
• PREVIEW: LINUX CONTAINERS ON WINDOWS
https://blog.docker.com/2017/09/preview-linux-containers-on-windows/
• Sneak peek #3: Windows Server, version 1709 for developers
https://blogs.technet.microsoft.com/windowsserver/2017/09/13/sneak-peek-3-windows-server-version-1709-for-
developers/
• Windows Networking at Parity with Linux for Kubernetes
https://www.cncf.io/blog/2017/09/08/windows-networking-parity-linux-kubernetes/
• Windows Server の半期チャネルの概要
https://docs.microsoft.com/ja-jp/windows-server/get-started/semi-annual-channel-overview
• Windows Insider Preview: Nested Virtualization
https://blogs.technet.microsoft.com/virtualization/2015/10/13/windows-insider-preview-nested-virtualization/
• Run Hyper-V in a Virtual Machine with Nested Virtualization
https://docs.microsoft.com/ja-jp/virtualization/hyper-v-on-windows/user-guide/nested-virtualization
• Changes to Nano Server in the next release of Windows Server
https://docs.microsoft.com/en-us/windows-server/get-started/nano-in-semi-annual-channel
29Copyright © 2017 System Center User Group Japan. All Rights Reserved.
Q&A
??
30Copyright © 2017 System Center User Group Japan. All Rights Reserved.

More Related Content

PDF
他山の石勉強会 DRBD編
PDF
Dockerライフサイクルの基礎 地雷を踏み抜けろ!
PDF
Pacemakerを使いこなそう
PDF
IIJにおけるGlusterFS利用事例 GlusterFSの詳解と2年間の運用ノウハウ
 
PDF
より速く より運用しやすく 進化し続けるJVM(Java Developers Summit Online 2023 発表資料)
PPTX
MongoDBが遅いときの切り分け方法
PDF
VirtualBox と Rocky Linux 8 で始める Pacemaker ~ VirtualBox でも STONITH 機能が試せる! Vi...
PPTX
iostat await svctm の 見かた、考え方
他山の石勉強会 DRBD編
Dockerライフサイクルの基礎 地雷を踏み抜けろ!
Pacemakerを使いこなそう
IIJにおけるGlusterFS利用事例 GlusterFSの詳解と2年間の運用ノウハウ
 
より速く より運用しやすく 進化し続けるJVM(Java Developers Summit Online 2023 発表資料)
MongoDBが遅いときの切り分け方法
VirtualBox と Rocky Linux 8 で始める Pacemaker ~ VirtualBox でも STONITH 機能が試せる! Vi...
iostat await svctm の 見かた、考え方

What's hot (20)

PDF
Fibre Channel 基礎講座
PDF
マイクロサービスに至る歴史とこれから - XP祭り2021
PPTX
OpenStackで始めるクラウド環境構築入門
PDF
Consulを頑張って理解する
PDF
YugabyteDBを使ってみよう - part2 -(NewSQL/分散SQLデータベースよろず勉強会 #2 発表資料)
PDF
vSphere 7 へのアップグレードについて
PDF
Apache Bigtop3.2 (仮)(Open Source Conference 2022 Online/Hiroshima 発表資料)
PPTX
サポート エンジニアが Azure Networking をじっくりたっぷり語りつくす会
PDF
TIME_WAITに関する話
PPTX
え、まって。その並列分散処理、Kafkaのしくみでもできるの? Apache Kafkaの機能を利用した大規模ストリームデータの並列分散処理
PDF
Btrfs + Snapper + Samba で作る「以前のバージョン」に戻せるファイルサーバー
PDF
PostgreSQLのリカバリ超入門(もしくはWAL、CHECKPOINT、オンラインバックアップの仕組み)
PPTX
Dockerからcontainerdへの移行
PDF
Ws2012フェールオーバークラスタリングdeep dive 130802
PDF
オープンソースのクラウド基盤 CloudStackによるIaaS構築入門 @OSC 2013 Nagoya
PDF
Oracle Data Guard による高可用性
PDF
Spring Boot の Web アプリケーションを Docker に載せて AWS ECS で動かしている話
PDF
PGOを用いたPostgreSQL on Kubernetes入門(Open Source Conference 2023 Online/Hokkaido...
PDF
これからのJDK 何を選ぶ?どう選ぶ? (v1.2) in 熊本
PPTX
コンテナネットワーキング(CNI)最前線
Fibre Channel 基礎講座
マイクロサービスに至る歴史とこれから - XP祭り2021
OpenStackで始めるクラウド環境構築入門
Consulを頑張って理解する
YugabyteDBを使ってみよう - part2 -(NewSQL/分散SQLデータベースよろず勉強会 #2 発表資料)
vSphere 7 へのアップグレードについて
Apache Bigtop3.2 (仮)(Open Source Conference 2022 Online/Hiroshima 発表資料)
サポート エンジニアが Azure Networking をじっくりたっぷり語りつくす会
TIME_WAITに関する話
え、まって。その並列分散処理、Kafkaのしくみでもできるの? Apache Kafkaの機能を利用した大規模ストリームデータの並列分散処理
Btrfs + Snapper + Samba で作る「以前のバージョン」に戻せるファイルサーバー
PostgreSQLのリカバリ超入門(もしくはWAL、CHECKPOINT、オンラインバックアップの仕組み)
Dockerからcontainerdへの移行
Ws2012フェールオーバークラスタリングdeep dive 130802
オープンソースのクラウド基盤 CloudStackによるIaaS構築入門 @OSC 2013 Nagoya
Oracle Data Guard による高可用性
Spring Boot の Web アプリケーションを Docker に載せて AWS ECS で動かしている話
PGOを用いたPostgreSQL on Kubernetes入門(Open Source Conference 2023 Online/Hokkaido...
これからのJDK 何を選ぶ?どう選ぶ? (v1.2) in 熊本
コンテナネットワーキング(CNI)最前線
Ad

Similar to Windows Server 2016上でLinuxコンテナが動いた! (20)

PDF
Windows Server 2016でコンテナを動かしてみた
PDF
はじめてのコンテナーDocker & Windows & Linux
PDF
コンテナ on Windows
PDF
Windows Server 2019 で Container を使ってみる
PDF
ソフトウェア工学2023 06 コンテナ仮想化
PDF
【18-E-3】クラウド・ネイティブ時代の2016年だから始める Docker 基礎講座
PDF
Getting started with Windows Containers
PDF
使ってわかる 今どきのdocker超入門
PPTX
Docker入門~word press環境を作ってみる ハンズオン編 ver1.4~ pulic
PPTX
Docker入門 OSC 2018 Tokyo/Spring
PDF
Docker with RHEL7 技術勉強会
PPTX
Web サービス インフラの近未来
PPTX
LinAction Theme Docker
PDF
Docker事始めと最新動向 2015年6月
PDF
Docker/Aarukas入門ハンズオン資料~第1回さくらとコンテナの夕べ #さくらの夕べ 番外編
PPTX
DockerをRed Hatはどのように見ているのか
PDF
Docker入門-基礎編 いまから始めるDocker管理【2nd Edition】
PPTX
Docker超入門
PDF
コンテナ情報交換会2
PDF
Docker入門: コンテナ型仮想化技術の仕組みと使い方
Windows Server 2016でコンテナを動かしてみた
はじめてのコンテナーDocker & Windows & Linux
コンテナ on Windows
Windows Server 2019 で Container を使ってみる
ソフトウェア工学2023 06 コンテナ仮想化
【18-E-3】クラウド・ネイティブ時代の2016年だから始める Docker 基礎講座
Getting started with Windows Containers
使ってわかる 今どきのdocker超入門
Docker入門~word press環境を作ってみる ハンズオン編 ver1.4~ pulic
Docker入門 OSC 2018 Tokyo/Spring
Docker with RHEL7 技術勉強会
Web サービス インフラの近未来
LinAction Theme Docker
Docker事始めと最新動向 2015年6月
Docker/Aarukas入門ハンズオン資料~第1回さくらとコンテナの夕べ #さくらの夕べ 番外編
DockerをRed Hatはどのように見ているのか
Docker入門-基礎編 いまから始めるDocker管理【2nd Edition】
Docker超入門
コンテナ情報交換会2
Docker入門: コンテナ型仮想化技術の仕組みと使い方
Ad

More from Takashi Kanai (10)

PDF
Rancher2.3とwindows Containerで作るkubernetesクラスタ
PDF
KubernetesとFlannelでWindows上にPod間VXLAN Overlayネットワークを構成
PDF
Kubernetes上のWindows Server コンテナーのマイクロサービス間分離
PDF
Toward Scalable and Powerful CloudStack
PDF
Kubernetes、Flannel、CNIでWindows Container Clusterオーケストレーション
PDF
Kubernetes1.9でWindowsコンテナーをクラスタ化
PDF
Rancherでwindows server上のコンテナを管理できるか
PDF
Chefで始めるWindows Server構築
PDF
App controllerとwindows azure packで作る大規模プライベートクラウド
PDF
App controllerとSPFで実現するハイブリッドクラウド
Rancher2.3とwindows Containerで作るkubernetesクラスタ
KubernetesとFlannelでWindows上にPod間VXLAN Overlayネットワークを構成
Kubernetes上のWindows Server コンテナーのマイクロサービス間分離
Toward Scalable and Powerful CloudStack
Kubernetes、Flannel、CNIでWindows Container Clusterオーケストレーション
Kubernetes1.9でWindowsコンテナーをクラスタ化
Rancherでwindows server上のコンテナを管理できるか
Chefで始めるWindows Server構築
App controllerとwindows azure packで作る大規模プライベートクラウド
App controllerとSPFで実現するハイブリッドクラウド

Windows Server 2016上でLinuxコンテナが動いた!

  • 2. 自己紹介 • 名前:金井 崇 • 所属:株式会社IDCフロンティア • 仕事:IaaSの基盤設計・構築・運用・提案を担当 • 興味:仮想化 コンテナ オールフラッシュ GPU FPGA Chef Docker PowerShell VSCode Hadoop • MVP:Cloud and Data Center Management (2017/03~) • SNSなど: • Facebook https://www.facebook.com/anikundesu • Blog http://www.takanyan.net/ • Twitter @anikundesu • LinkedIn https://jp.linkedin.com/in/takashikanai/ja • SlideShare https://www.slideshare.net/anikundesu/presentations 2Copyright © 2017 System Center User Group Japan. All Rights Reserved.
  • 3. 注意事項 本セッションは、Windows Server Insider Preview 16278での検証結果をもとに記述をしています。 正式版では挙動が異なる場合がありますので、ご留意ください。 本セッション資料は、個人で準備した環境において、個人的に実施した検証・結果を基に記載して います。あくまで個人の意見・見解であり、所属する会社・組織及びマイクロソフト社とは関係が ございません。所属する会社・組織・マイクロソフト社の正式な回答・見解ではない事に留意して ください。 本資料を閲覧した事により問題が生じた場合、または問題が発生しかけた場合、または生じた一切 の不利益について、発表者は一切の責任を負う事はできませんのでご了承ください。 3Copyright © 2017 System Center User Group Japan. All Rights Reserved.
  • 5. Windows Server Semi-Annual Release 1709のコンテナ向け新機能紹介 Section 1 5Copyright © 2017 System Center User Group Japan. All Rights Reserved.
  • 6. Semi-Annualu Release 1709の新機能 <コンテナ関連でアナウンスされた新機能> 1. 新しいコンテナベースイメージ – Nano Server:70%以上縮小され80MBに – Server Core :20%以上縮小 2. コンテナがSMBボリュームのマウントをサポート 3. コンテナオーケストレーター向け基盤 – KubernetesクラスターでLinuxと同等のネットワーク機能をサポート – Named pipe mapping対応 <正式アナウンスされていない新機能> 4. Hyper-Vコンテナー+LinuxKITでLinuxカーネルベースのコンテナに対応 6Copyright © 2017 System Center User Group Japan. All Rights Reserved.
  • 7. Nano Serverはコンテナー専用 • Nano Serverは.NET Coreアプリケーションの動作に最適化 • PowerShell、.NET Core、WMIはデフォルト非搭載 – ユーザーが自分のコンテナーイメージを作る際にPowerShell や.NET Coreコンテナパッケージを追加することは可能 • アップデートはDockerHub経由で新しいイメージを配布 • Nano ServerのトラブルシュートはDockerを使う – “docker run (イメージ名) –ti cmd”など • Windows IoT Core上でNano Serverのコンテナが起動可能 • Nano ServerのVMイメージは廃止 7Copyright © 2017 System Center User Group Japan. All Rights Reserved. 出典:Changes to Nano Server in the next release of Windows Server https://docs.microsoft.com/en-us/windows-server/get-started/nano-in-semi-annual-channel
  • 8. Kubernetes対応することの意味 • Kubernetesはコンテナオーケスト レーターの(ほぼ)標準 • コンテナクラスタを作るために必要 なSDNもLinux Kernelの機能で実装 • WindowsはこのSDN実装に対応 KubernetesクラスタをWindowsだけで 作れるようになる 8Copyright © 2017 System Center User Group Japan. All Rights Reserved. 出典:Windows Networking at Parity with Linux for Kubernetes https://www.cncf.io/blog/2017/09/08/windows-networking-parity-linux-kubernetes/ Windows Server 1709での Kubernetes Network機能対応
  • 10. Linuxカーネルが動く仕組みの概要 1. 基本はHyper-Vコンテナー 2. Hyper-VゲストOSはLinuxKit(極小Linux) 3. WSL(Windows Subsystem for Linux)は使ってい ない! 10Copyright © 2017 System Center User Group Japan. All Rights Reserved.
  • 11. 【復習】Hyper-Vコンテナー • 一つのコンテナに1つのOS • Docker APIでHyper-Vの仮想環境を操作 11 Windowsホスト OS Kernel VM1 VM2 Process1 Process2 Docker Engine ホスト Process Docker Client Docker API Hyper-V ゲスト1 Win Kernel ゲスト2 Win Kernel Copyright © 2017 System Center User Group Japan. All Rights Reserved.
  • 12. Hyper-Vコンテナー上のLinuxKit • 一つのコンテナに1つのLinuxKIT OS • Docker APIでHyper-Vの仮想環境を操作 12 Windowsホスト OS Kernel VM1 VM2 Docker Engine ホスト Process Docker Client Docker API Hyper-V ゲスト1 ゲスト2 Copyright © 2017 System Center User Group Japan. All Rights Reserved. Process1 Process2
  • 13. LinuxKITの実体 • LinuxKITはコンテナを起動させるために最低限必要なLinux • Hyper-V仮想マシン起動に必要なEFIファームウェアとLinuxメモリイメー ジのみで構成 • dockerでコンテナ作成の命令が来るとこれらのファイルで自動的に UtilityVMというものが作られ、その中でLinuxコンテナが起動される。 13Copyright © 2017 System Center User Group Japan. All Rights Reserved. PS C:¥Program Files¥Linux Containers> ls Directory: C:¥Program Files¥Linux Containers Mode LastWriteTime Length Name ---- ------------- ------ ---- -a---- 2017/09/07 11:59 6845200 bootx64.efi -a---- 2017/09/07 11:59 7235724 initrd.img
  • 14. Docker for Windowsとの違い • Hyper-V上にLinux仮想マシンを1つ作成(MobyLinuxVM) • Docker APIでLinux仮想マシン上のコンテナを操作 14 Windowsホスト OS Kernel VM Docker Engine ホスト Process Docker Client Docker API Hyper-V Linux Kernel (MobyLinuxVM) Linuxコンテナ Process1 Linuxコンテナ Process2 Copyright © 2017 System Center User Group Japan. All Rights Reserved.
  • 16. Hyper-V デモでやりたかったこと • ホストOSをWindows Server Insider Preview build 16278 • Hyper-VコンテナーでLinuxKIT動作を「見せたい」 16 Windows Server Insider 16278 OS Kernel VM1 VM2 Docker Engine ホスト Process Docker Client Docker API ゲスト1 ゲスト2 Copyright © 2017 System Center User Group Japan. All Rights Reserved. Process1 Process2
  • 17. Semi-Annual Releaseの特徴 Desktopエクスペリエンスなし! デモを「見せられない」 17Copyright © 2017 System Center User Group Japan. All Rights Reserved. 出典:Windows Server の半期チャネルの概要 https://docs.microsoft.com/ja-jp/windows-server/get-started/semi-annual-channel-overview インストール オプション 半期チャネル (Windows Server) Long-term Servicing チャネル (Windows Server 2016) Nano Server 〇 × Server Core 〇 〇 デスクトップ搭載サーバー × 〇
  • 18. Hyper-V(親) Windows Server 2016 (Win2k16host) Nested Hyper-V (VM名:Win2016-build16278) 本日のデモ環境の構成 Nested Hyper-Vを使って1PCで実現 18 VM1 VM2 Docker Engine ゲスト1 ゲスト2 Copyright © 2017 System Center User Group Japan. All Rights Reserved. Process1 Process2 この プレゼン Windows Server Insider 16278 (Win2016-Guest) Docker Client Docker API
  • 19. Nested Hyper-V構築手順 1. Windows Server Insider用VM作成(OSはまだ不要) 2. NestedVMを有効にするScriptをダウンロード https://github.com/MicrosoftDocs/Virtualization- Documentation/blob/master/hyperv-tools/Nested/Enable-NestedVm.ps1 3. Scriptを1.の仮想マシン名を引数に指定して実行 19Copyright © 2017 System Center User Group Japan. All Rights Reserved. PS D:¥> .¥Enable-NestedVm.ps1 【VM名】 This script will set the following for 【VM名】 in order to enable nesting: Virtualization extensions will be enabled Optionally enable mac address spoofing Input Y to accept or N to cancel:Y Mac Address Spoofing isn't enabled (nested guests won't have network). Would you like to enable MAC address spoofing? (Y/N)Y MACアドレスSpoofing も有効にする
  • 20. Windows Server Insider Previewセットアップ 1. Windows Insiderページから ISOを入手 2. Nested VM上でServer Core をインストール 3. インストール後、sconfigコ マンドで初期設定 – ホスト名の設定 – IPアドレスなどNetwork設定 – Remote Desktop接続有効化 20Copyright © 2017 System Center User Group Japan. All Rights Reserved.
  • 21. 複数のPowerShellセッションを使う準備 Enter-PSSessionコマンドレットを使ってリモートから PowerShell実行ができるようにする <接続先(Insider Preview)での設定> <接続元クライアントでの設定> 21Copyright © 2017 System Center User Group Japan. All Rights Reserved. C:¥> winrm quickconfig PS C:¥> set-item WSMan:¥localhost¥Client¥TrustedHosts -Value 【接続先IP】 PS C:¥> Enter-PSSession -Computername 【接続先IP】 -Credential Administrator
  • 22. Hyper-Vコンテナー構築手順 1. Hyper-VとContainer機能を有効化とOS再起動 2. Docker 17.06.0-ceのインストールとOS再起動 22Copyright © 2017 System Center User Group Japan. All Rights Reserved. PS C:¥> Install-WindowsFeature Hyper-V,Containers –IncludeManagementTools PS C:¥> Restart-Comptuer -Force PS C:¥> Install-Module -Name DockerMsftProviderInsider -Repository PSGallery -Force PS C:¥> Install-Package -Name docker -ProviderName DockerMsftProviderInsider - RequiredVersion 17.06.0-ce Docker CE 17.06を明示的に指定しないと、Linuxベースの コンテナが動かないです。(2017年9月30日時点)
  • 23. LinuxKITとDockerデーモン準備 1. LinuxKITのダウンロードと展開 2. Linuxコンテナ on Windows対応Dockerデーモン展開 23Copyright © 2017 System Center User Group Japan. All Rights Reserved. PS C:¥> mkdir "$Env:ProgramFiles¥Linux Containers" PS C:¥> Invoke-WebRequest -UseBasicParsing -OutFile linuxkit.zip https://github.com/friism/linuxkit/releases/download/preview-1/linuxkit.zip PS C:¥> Expand-Archive linuxkit.zip -DestinationPath "$Env:ProgramFiles¥Linux Containers¥.“ PS C:¥> rm linuxkit.zip PS C:¥> mkdir “$Env:ProgramFiles¥lcow” ←dockerデーモンのインストールフォルダ作成 PS C:¥> cd "$Env:ProgramFiles¥lcow" PS C:¥Program Files¥lcow¥> Invoke-WebRequest -UseBasicParsing -OutFile dockerd.exe https://master.dockerproject.org/windows/x86_64/dockerd.exe PS C:¥Program Files¥lcow¥> mkdir C:¥lcow ←コンテナイメージの保存フォルダを事前作成
  • 24. DEMO:Linuxコンテナ on Windows 1. Linuxコンテナ起動用Dockerデーモンの起動 2. Linuxコンテナの起動 3. Windowsコンテナ起動用Dockerデーモンと比較 24Copyright © 2017 System Center User Group Japan. All Rights Reserved.
  • 25. Linuxコンテナ起動用Dockerデーモンの起動 1. リモートからPowerShell接続してデーモン起動 2. RDPまたはローカルの「コマンドプロンプト」でLinux カーネルベースのコンテナを起動 25Copyright © 2017 System Center User Group Japan. All Rights Reserved. PS C:¥> Enter-PSSession -Computername 【接続先IP】 -Credential Administrator [【接続先IP】 ]: PS C:¥Users¥Administrator¥Documents> cd "$Env:ProgramFiles¥lcow¥” [【接続先IP】 ]: PS C:¥Program Files¥lcow> $Env:LCOW_SUPPORTED=1 [【接続先IP】 ]: PS C:¥Program Files¥lcow> .¥dockerd.exe -D --experimental -H "npipe:////./pipe//docker_lcow" --data-root c:¥lcow C:¥> docker -H "npipe:////./pipe//docker_lcow" run -ti busybox sh / # (←Linuxベースのコンテナでシェルが起動)
  • 26. Windowsコンテナ起動用Dockerデーモンと比較 C:¥> docker -H "npipe:////./pipe//docker_lcow" version Client: Version: 17.06.0-ce API version: 1.30 Go version: go1.8.3 Git commit: 02c1d87 Built: Fri Jun 23 21:30:30 2017 OS/Arch: windows/amd64 Server: Version: master-dockerproject-2017-09-29 API version: 1.33 (minimum version 1.24) Go version: go1.8.3 Git commit: ab2b03a Built: Fri Sep 29 23:51:45 2017 OS/Arch: windows/amd64 Experimental: true C:¥> docker version Client: Version: 17.06.0-ce API version: 1.30 Go version: go1.8.3 Git commit: 02c1d87 Built: Fri Jun 23 21:30:30 2017 OS/Arch: windows/amd64 Server: Version: 17.06.0-ce API version: 1.30 (minimum version 1.24) Go version: go1.8.3 Git commit: 02c1d87 Built: Fri Jun 23 22:19:00 2017 OS/Arch: windows/amd64 Experimental: false 26Copyright © 2017 System Center User Group Japan. All Rights Reserved. LCOW対応版Dockerデーモン 通常のWindows用Dockerデーモン
  • 27. まとめ Section 4 27Copyright © 2017 System Center User Group Japan. All Rights Reserved.
  • 28. まとめ • Windows Server Semi-Annualu Release 1709はDesktop機能な しでリリース。 • Windows ServerはWindowsだけではなくLinuxのコンテナにも対 応。オーケストレーターとしてKubernetesをサポートする。 • Linux Kernelベースのコンテナを実行するため、Hyper-Vコンテナ でLinuxKIT(コンテナ実行用の極小Linux)を利用している。 28Copyright © 2017 System Center User Group Japan. All Rights Reserved.
  • 29. 参考資料 • PREVIEW: LINUX CONTAINERS ON WINDOWS https://blog.docker.com/2017/09/preview-linux-containers-on-windows/ • Sneak peek #3: Windows Server, version 1709 for developers https://blogs.technet.microsoft.com/windowsserver/2017/09/13/sneak-peek-3-windows-server-version-1709-for- developers/ • Windows Networking at Parity with Linux for Kubernetes https://www.cncf.io/blog/2017/09/08/windows-networking-parity-linux-kubernetes/ • Windows Server の半期チャネルの概要 https://docs.microsoft.com/ja-jp/windows-server/get-started/semi-annual-channel-overview • Windows Insider Preview: Nested Virtualization https://blogs.technet.microsoft.com/virtualization/2015/10/13/windows-insider-preview-nested-virtualization/ • Run Hyper-V in a Virtual Machine with Nested Virtualization https://docs.microsoft.com/ja-jp/virtualization/hyper-v-on-windows/user-guide/nested-virtualization • Changes to Nano Server in the next release of Windows Server https://docs.microsoft.com/en-us/windows-server/get-started/nano-in-semi-annual-channel 29Copyright © 2017 System Center User Group Japan. All Rights Reserved.
  • 30. Q&A ?? 30Copyright © 2017 System Center User Group Japan. All Rights Reserved.