windows container
windows server2022をwindows nodeとしてmicrok8sクラスタに追加して運用中
参考
https://qiita.com/ishibashi-futoshi/items/db807d64624f43be1be9
https://blog.jp.square-enix.com/iteng-blog/posts/00040-windows-container-with-docker/
windowsでビルドする際にローカルwindowsでdockerを有効化する
windows のdockerはバックエンドがdefaultでWSL2である
windows containerをうごかすにはWSL2バックエンドでは動かない
windows backendにする
事前にHyper-Vとcontainersの機能を有効化しておくこと
code:powershell
Enable-WindowsOptionalFeature -Online -FeatureName containers -All
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All
https://qiita.com/rabut/items/a522bf6408e3a9b69937#dockerエンジンwindows側のインストール
windows containerでのDockerfile
https://learn.microsoft.com/ja-jp/virtualization/windowscontainers/manage-docker/manage-windows-dockerfile
windows contaienrはホストよりも古い環境でも動作はする
build時は--platformを指定しないとマニフェストがなくてimage downloadできないので注意
docker build --platform windows/amd64 ./
builderkitがwindowsに対応してないのでbuildxは使えない
chocolatyをインストール
code:chocolaty install
RUN Set-ExecutionPolicy Bypass -Scope Process -Force; System.Net.ServicePointManager::SecurityProtocol = System.Net.ServicePointManager::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
コンテナイメージログイン
docker run -it --rm <image> powershell
SSH server
code:powersherll
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0
Start-Service sshd
Set-Service -Name sshd -StartupType 'Automatic'
New-NetFirewallRule -Name 'OpenSSH-Server-In-TCP' -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22