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:ltsc2025
SHELL ["powershell", "-command"]
RUN Install-WindowsFeature Web-Server
RUN Invoke-WebRequest -Uri https://dotnetbinaries.blob.core.windows.net/servicemonitor/2.0.1.10/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 = @"
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 432B
Step 1/7 : FROM mcr.microsoft.com/windows/servercore:ltsc2025
---> f9fb7d5c26c9
Step 2/7 : SHELL ["powershell", "-command"]
[+] Running 0/1
[+] Running 0/1 Building
- Service web Building
---> Removed intermediate container 65214e2180ce
[+] Running 0/1e6f
[+] Running 0/1 Building
- Service web Building
.....
.....
[+] Running 0/140e
[+] Running 0/1 Building
- Service web Building
---> Removed intermediate container b0035ab37f37
---> 9d2d11c741f2
[+] Running 3/3ilt 9d2d11c741f2
✓ Service web Built
✓ Network docker-file_default Created
✓ Container docker-file-web-1 Started
PS C:\Users\Administrator\docker-file> docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c8201674845f docker-file-web "C:\\ServiceMonitor.e…" About a minute ago Up About a minute 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
|