Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
# create Dockerfile
PS C:\Users\Administrator> mkdir docker-file
PS C:\Users\Administrator> cd docker-file
PS C:\Users\Administrator\docker-file> $str_file = @"
FROM mcr.microsoft.com/windows/servercore:ltsc2022
SHELL ["powershell", "-command"]
RUN Install-WindowsFeature Web-Server
RUN Invoke-WebRequest -Uri https://dotnetbinaries.blob.core.windows.net/servicemonitor/2.0.1.6/ServiceMonitor.exe -OutFile C:\ServiceMonitor.exe
EXPOSE 80
ENTRYPOINT ["C:\\ServiceMonitor.exe", "w3svc"]
"@
PS C:\Users\Administrator\docker-file> $str_file | Out-File Dockerfile -Encoding Default
# define application configration
PS C:\Users\Administrator\docker-file> $str_file2 = @"
version: '3'
services:
web:
build: .
ports:
- "80:80"
volumes:
- C:\iis:C:\inetpub\wwwroot
"@
PS C:\Users\Administrator\docker-file> $str_file2 | Out-File docker-compose.yml -Encoding Default
PS C:\Users\Administrator\docker-file> mkdir C:\iis
# buid and run
PS C:\Users\Administrator\docker-file> docker-compose up -d
Sending build context to Docker daemon 513B
Step 1/6 : FROM mcr.microsoft.com/windows/servercore:ltsc2022
---> 11cbc9e36c7a
Step 2/6 : SHELL ["powershell", "-command"]
---> Running in e70646a28478
Removing intermediate container e70646a28478
---> 9e1231e7ae71
Step 3/6 : RUN Install-WindowsFeature Web-Server
---> Running in d7c2c18180cb
.....
.....
Step 6/6 : ENTRYPOINT ["C:\\ServiceMonitor.exe", "w3svc"]
---> Running in b7ab30b05ce9
Removing intermediate container b7ab30b05ce9
---> db13c58d6184
Successfully built db13c58d6184
Successfully tagged docker-file_web:latest
[+] Running 1/1
- Container docker-file-web-1 Started
PS C:\Users\Administrator\docker-file> docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
71bdab92e0d5 docker-file_web "C:\\ServiceMonitor.e…" 19 seconds ago Up 17 seconds 0.0.0.0:80->80/tcp docker-file-web-1
# create a test file
PS C:\Users\Administrator\docker-file> Write-Output "Docker Compose Test Page" | Out-File C:\iis\Default.htm -Encoding Default
# verify accesses
PS C:\Users\Administrator\docker-file> curl.exe localhost
Docker Compose Test Page
|