Jump to content
Toggle menu
  • 51 articles
  • 24 files
  • 4 users
  • 750 edits
Tech-Wiki
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Running Docker containers

From Tech-Wiki


Windows container examples covering image pulls, interactive containers, image commits, Dockerfiles, IIS containers and remote IIS management.

Pull and run a Nano Server image

>_Pull Nano Server
docker pull mcr.microsoft.com/windows/nanoserver:ltsc2022

List local images:

>_List images
docker images

Start an interactive container:

>_Run Nano Server
docker run -it mcr.microsoft.com/windows/nanoserver:ltsc2022 cmd.exe

Inside the container:

echo "Hello World!" > Hello.txt
exit

Commit a modified container

>_Review stopped containers
docker ps -a
>_Create an image from a container
docker commit <containerid> helloworld

Run the resulting image:

>_Read the sample file
docker run --rm helloworld cmd.exe /s /c type Hello.txt

IIS container

>_Pull the Windows IIS image
docker pull mcr.microsoft.com/windows/servercore/iis

Example Dockerfile:

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
WORKDIR /inetpub/wwwroot
COPY app1/ .

Build and run:

>_Build the image
docker build -t test-image .
>_Run the IIS container
docker run -d -p 8080:80 --name test-container test-image

Inspect the container IP information:

docker inspect -f "{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}" test-container

IIS Manager remote administration example

The original article enables the IIS Management Service and creates a local administrator inside the image:

FROM mcr.microsoft.com/windows/servercore/iis:windowsservercore-ltsc2022
RUN net user admin p4ssw0rd /ADD
RUN net localgroup administrators admin /ADD
RUN powershell.exe -command \
 Install-WindowsFeature Web-Mgmt-Service; \
 Set-ItemProperty -Path "HKLM:SOFTWARE\Microsoft\WebManagement\Server" -Name "EnableRemoteManagement" -Value 1; \
 Set-Service WMSVC -StartupType Automatic;
!
Do not reuse example passwords
Replace the demonstration local-account password with an approved secret-management approach before using a similar build in another environment.

See also