Difference between revisions of "Running Docker containers"
From Tech-Wiki
Line 45: | Line 45: | ||
FROM mcr.microsoft.com/windows/servercore/iis:windowsservercore-ltsc2022 | FROM mcr.microsoft.com/windows/servercore/iis:windowsservercore-ltsc2022 | ||
RUN powershell.exe -command ` | RUN powershell.exe -command ` | ||
− | + | net user admin p4ssw0rd /ADD; ` | |
− | + | net localgroup administrators /ADD | |
RUN powershell.exe -command ` | RUN powershell.exe -command ` | ||
− | + | Install-WindowsFeature Web-Mgmt-Service; ` | |
− | + | Set-ItemProperty -Path HKLM:SOFTWAREMicrosoftWebManagementServer -Name EnableRemoteManagement -Value 1; ` | |
− | + | Set-Service WMSVC -StartupType Automatic | |
− | + | docker run -d -p 8080:80 -p 8172:8172 iisremote:v1 |
Revision as of 20:50, 27 August 2023
Install Container feature, install Docker.
Pull an image
docker pull mcr.microsoft.com/windows/nanoserver:ltsc2022
List images
docker images
Run image
docker run -it mcr.microsoft.com/windows/nanoserver:ltsc2022 cmd.exe echo "Hello World!" > Hello.txt exit
Update image
docker ps -a docker commit <containerid> helloworld docker ps -a (now it shows 2)
Run this custom image
docker run --rm helloworld cmd.exe /s /c type Hello.txt
Pull IIS
docker pull mcr.microsoft.com/windows/servercore/iis
Dockerfile example
FROM mcr.microsoft.com/windows/servercore/iis RUN mkdir C:\Temp COPY *.ps1 /Temp RUN powershell -Command blah blah… RUN powershell -File /Temp/blah.ps1 ADD www-files /inetpub/wwwroot
Run it
docker build -t test-image . docker run -d -p 8080:80 --name test-container test-image docker inspect -f "Template:Range .NetworkSettings.NetworksTemplate:.IPAddressTemplate:End" test-container
For IIS, install IIS Manager for Remote Administrator, create local account on container, and enable service
# escape=` FROM mcr.microsoft.com/windows/servercore/iis:windowsservercore-ltsc2022 RUN powershell.exe -command ` net user admin p4ssw0rd /ADD; ` net localgroup administrators /ADD RUN powershell.exe -command ` Install-WindowsFeature Web-Mgmt-Service; ` Set-ItemProperty -Path HKLM:SOFTWAREMicrosoftWebManagementServer -Name EnableRemoteManagement -Value 1; ` Set-Service WMSVC -StartupType Automatic
docker run -d -p 8080:80 -p 8172:8172 iisremote:v1