Windowsのコンテナを作ろう
Dockerといえば、普通はLinuxのコンテナですが、Windowsのコンテナを使いたいときもあると思います。
そんなボーイズ&ガールズにWindowsのコンテナを作るDockerfileをお贈りしよう。
GO言語の実行環境を構築
試しにGO言語の実行環境を構築してみます。
環境が変わればプレイングも変わるのが常ですが、
GOはオールラウンダーなので、さほど変わりませんから楽ですね。
FROM mcr.microsoft.com/windows:1909
ENV GOLANG_VERSION 1.14.10
ENV GOLANG_DOWNLOAD_URL "https://golang.org/dl/go$GOLANG_VERSION.windows-amd64.zip"
RUN powershell -Command \
$ErrorActionPreference = 'Stop'; \
(New-Object System.Net.WebClient).DownloadFile('%GOLANG_DOWNLOAD_URL%', 'go.zip') ; \
Expand-Archive go.zip -DestinationPath c:\\ ; \
Remove-Item go.zip -Force
RUN setx PATH %PATH%;c:\go\bin
Docker for Windowsで動かす場合は、「Switch to Windows containers」で
Windowsコンテナ稼働モードにしてください。