Docs / Windows Server / Run Docker on Windows Server

Run Docker on Windows Server

By Admin · Mar 15, 2026 · Updated Apr 23, 2026 · 166 views · 4 min read

Docker on Windows Server enables you to run both Windows and Linux containers for application deployment. Windows Server includes native container support with Docker Enterprise, allowing you to containerize legacy .NET applications and run modern microservices. This guide covers installing and using Docker on your Windows Server VPS.

Install Docker on Windows Server

# Install the Containers feature
Install-WindowsFeature -Name Containers -Restart

# After reboot, install Docker
Install-Module -Name DockerMsftProvider -Repository PSGallery -Force
Install-Package -Name docker -ProviderName DockerMsftProvider -Force

# Start Docker service
Start-Service docker
Set-Service docker -StartupType Automatic

# Verify installation
docker version
docker info

Running Windows Containers

# Pull Windows Server Core base image
docker pull mcr.microsoft.com/windows/servercore:ltsc2022

# Pull Nano Server (smaller)
docker pull mcr.microsoft.com/windows/nanoserver:ltsc2022

# Run a Windows container
docker run -it mcr.microsoft.com/windows/servercore:ltsc2022 powershell

# Run IIS in a container
docker pull mcr.microsoft.com/windows/servercore/iis
docker run -d -p 8080:80 --name my-iis mcr.microsoft.com/windows/servercore/iis

# Run SQL Server Express in a container
docker run -d -p 1433:1433 `
    --name sql-express `
    -e "ACCEPT_EULA=Y" `
    -e "MSSQL_SA_PASSWORD=YourStr0ng!Passw0rd" `
    mcr.microsoft.com/mssql/server:2022-latest

Running Linux Containers (LCOW)

# Enable Linux Containers on Windows (requires Hyper-V)
# In Docker daemon config, enable experimental mode and LCOW

# Create Docker daemon configuration
@{
    "experimental" = $true
} | ConvertTo-Json | Set-Content "C:\ProgramData\docker\config\daemon.json"

Restart-Service docker

# Run Linux containers with --platform flag
docker run -d --platform linux -p 8081:80 nginx
docker run -d --platform linux -p 5432:5432 `
    -e POSTGRES_PASSWORD=mysecretpassword postgres:16

Containerize a .NET Application

# Dockerfile for ASP.NET application
# Save as Dockerfile in your project directory

FROM mcr.microsoft.com/dotnet/aspnet:8.0-windowsservercore-ltsc2022 AS base
WORKDIR /app
EXPOSE 80 443

FROM mcr.microsoft.com/dotnet/sdk:8.0-windowsservercore-ltsc2022 AS build
WORKDIR /src
COPY ["MyApp.csproj", "."]
RUN dotnet restore
COPY . .
RUN dotnet build -c Release -o /app/build

FROM build AS publish
RUN dotnet publish -c Release -o /app/publish

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "MyApp.dll"]

# Build and run
docker build -t my-dotnet-app .
docker run -d -p 5000:80 --name myapp my-dotnet-app

Docker Compose on Windows

# docker-compose.yml for a Windows-based web stack
version: '3.8'
services:
  web:
    image: mcr.microsoft.com/dotnet/aspnet:8.0-windowsservercore-ltsc2022
    ports:
      - "80:80"
    depends_on:
      - db
    environment:
      - ConnectionStrings__DefaultConnection=Server=db;Database=MyApp;User=sa;Password=YourStr0ng!Pass;

  db:
    image: mcr.microsoft.com/mssql/server:2022-latest
    environment:
      - ACCEPT_EULA=Y
      - MSSQL_SA_PASSWORD=YourStr0ng!Pass
    volumes:
      - sqldata:/var/opt/mssql

volumes:
  sqldata:

# Deploy
docker-compose up -d
docker-compose ps
docker-compose logs -f

Container Networking

# List networks
docker network ls

# Create NAT network (default on Windows)
docker network create -d nat --subnet=172.28.0.0/16 my-nat-network

# Create transparent network (bridged)
docker network create -d transparent my-transparent-network

# Connect container to network
docker network connect my-nat-network my-container

# Run container on specific network
docker run -d --network my-nat-network --name web nginx

Volume Management

# Create named volume
docker volume create app-data

# Mount volume
docker run -d -v app-data:C:\app\data my-app

# Bind mount host directory
docker run -d -v C:\HostData:C:\ContainerData my-app

# List and inspect volumes
docker volume ls
docker volume inspect app-data

Windows Container Security

# Run with limited privileges
docker run -d --user ContainerUser my-app

# Use group Managed Service Accounts (gMSA)
# Create credential spec
New-CredentialSpec -AccountName "MyApp_gMSA" -Path "C:\ProgramData\docker\credentialspecs"

# Run with gMSA
docker run -d --security-opt "credentialspec=file://MyApp_gMSA.json" my-app

# Enable Windows Defender scanning for containers
Set-MpPreference -EnableContainerScan $true

Monitoring

# View container resource usage
docker stats

# View container logs
docker logs -f my-app --tail 100

# Inspect container
docker inspect my-app

# Check container health
docker run -d --health-cmd "powershell -Command try { Invoke-WebRequest http://localhost -UseBasicParsing; exit 0 } catch { exit 1 }" `
    --health-interval 30s --health-retries 3 my-app

Best Practices

  • Use Nano Server base images when possible — they're much smaller than Server Core
  • Match container OS version to the host OS version for Windows containers
  • Use multi-stage builds to keep final images small
  • Run containers as non-root (ContainerUser) for security
  • Use Docker Compose for multi-container applications
  • Configure resource limits (CPU, memory) on containers
  • Consider Linux containers for non-.NET workloads — broader ecosystem support

Was this article helpful?