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:ltsc2022
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:ltsc2022
---> 11cbc9e36c7a
Step 2/6 : MAINTAINER ServerWorld <admin@srv.world>
---> Running in c775d6cedbb1
Removing intermediate container c775d6cedbb1
---> 05582598eefe
Step 3/6 : RUN dism.exe /online /enable-feature /all /featurename:iis-webserver /NoRestart
---> Running in c92f3ef1c94e
.....
.....
Step 6/6 : CMD [ "cmd" ]
---> Running in b7c3e38a4740
Removing intermediate container b7c3e38a4740
---> 0eaa2396d003
Successfully built 0eaa2396d003
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 0eaa2396d003 2 minutes ago 5.07GB
mcr.microsoft.com/windows/servercore ltsc2022 11cbc9e36c7a 4 days ago 4.95GB
# バックグラウンドでコンテナーを起動
PS C:\Users\Administrator\docker-test> docker run -dt -p 8081:80 srv.world/iis-server
bb75b4501071296845a574ec2884f7de7d05e91988b9022b3e73225fbb3d3d9e
PS C:\Users\Administrator\docker-test> docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
bb75b4501071 srv.world/iis-server "cmd" 29 seconds ago Up 28 seconds 0.0.0.0:8081->80/tcp condescending_darwin
# アクセス確認
PS C:\Users\Administrator\docker-test> curl.exe localhost:8081
Dockerfile test example
|