Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
PS C:\Users\Administrator> mkdir docker-file
PS C:\Users\Administrator\docker-file> cd docker-file
# Dockerfile 作成
PS C:\Users\Administrator\docker-file> $str_file = @"
FROM mcr.microsoft.com/windows/servercore:ltsc2025
MAINTAINER ServerWorld <admin@srv.world>
RUN dism.exe /online /enable-feature /all /featurename:iis-webserver /NoRestart
RUN echo Dockerfile test example > C:\inetpub\wwwroot\index.html
EXPOSE 80
CMD [ "cmd" ]
"@
PS C:\Users\Administrator\docker-file> $str_file | Out-File Dockerfile -Encoding Default
# イメージのビルド ⇒ docker build -t [イメージ名]:[タグ] .
PS C:\Users\Administrator\docker-test> docker build -t srv.world/iis-server:latest .
Sending build context to Docker daemon 2.048kB
Step 1/6 : FROM mcr.microsoft.com/windows/servercore:ltsc2025
---> f9fb7d5c26c9
Step 2/6 : MAINTAINER ServerWorld <admin@srv.world>
---> Running in dd2309cd9314
---> Removed intermediate container dd2309cd9314
---> 9cdb2d813458
Step 3/6 : RUN dism.exe /online /enable-feature /all /featurename:iis-webserver /NoRestart
---> Running in 234621a86025
.....
.....
Step 6/6 : CMD [ "cmd" ]
---> Running in 333afe746605
---> Removed intermediate container 333afe746605
---> 4e3d76bef20a
Successfully built 4e3d76bef20a
Successfully tagged srv.world/iis-server:latest
PS C:\Users\Administrator\docker-test> docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
srv.world/iis-server latest 4e3d76bef20a 42 seconds ago 5.26GB
mcr.microsoft.com/windows/servercore ltsc2025 f9fb7d5c26c9 7 days ago 5.14GB
# バックグラウンドでコンテナーを起動
PS C:\Users\Administrator\docker-test> docker run -dt -p 8081:80 srv.world/iis-server
a5ae5ccab6c788d070c22c4c3542f3abe1de8905ee8914b24323c1a4f5180805
PS C:\Users\Administrator\docker-test> docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a5ae5ccab6c7 srv.world/iis-server "cmd" 10 seconds ago Up 8 seconds 0.0.0.0:8081->80/tcp funny_merkle
# アクセス確認
PS C:\Users\Administrator\docker-test> curl.exe localhost:8081
Dockerfile test example
|