Skip to content

About

No description, website, or topics provided.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Latest commit

 

History

340 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WinContainers

WinContainers

A focused Windows desktop manager for containers running through Microsoft's WSL Containers runtime (WSLC). WinContainers gives developers a small, native WinUI 3 interface for viewing and operating containers without Docker Desktop.

What It Does

  • View, start, stop, rename, and remove containers.
  • Pull, inspect, and remove container images.
  • Manage volumes and networks.
  • Open container logs and an interactive terminal.
  • Detect WSL2, virtualization, and WSLC prerequisites during onboarding.
  • Install or update WSLC from Microsoft's official WSL releases.
  • Check for Stable or Beta application updates.
  • Run as a portable app or install with the Windows setup executable.

Requirements

  • Windows 11.
  • WSL2 and virtualization enabled.
  • WSLC (wslc.exe) for container operations.
  • Administrator approval when installing WSL2 or WSLC.

The onboarding screen checks prerequisites and provides installation actions where possible.

Sessions and elevation

WSLC stores containers, images, volumes, and networks inside a session, and the session a wslc call lands in is chosen by the elevation level of the calling process — not by a flag. Each session has its own VHD-backed store under %LOCALAPPDATA%\wslc\sessions\:

Calling process Session directory Contents
Elevated wslc-cli-admin-<user> The store WinContainers manages
Non-elevated wslc-cli-<user> A separate, independent store

The two stores cannot see each other, and wslc container list has no --session option to switch between them. This is why WinContainers is launched elevated: the app, its in-process service, and the MCP server must all resolve to the same session, or the UI shows a different world than the one your containers live in.

The non-elevated session is WSLC's default, not a WinContainers concept. WSLC is designed to run containers without administrator rights, so any non-elevated caller — a terminal, a build script, CI — gets its own session created on demand. WinContainers does not need it; it lands in the admin session only because the app runs elevated. The non-elevated session is still useful as scratch space: the deploy skill builds images there so bind mounts and the volume-mount limit stay out of the admin session.

Elevation is required for two distinct reasons, and it is worth keeping them apart:

  1. Session identity — daily container operations need to run in the same session as the rest of your tooling. This is a WSLC design constraint, not a Windows privilege requirement.
  2. Privileged setup — enabling WSL2 and installing the WSLC MSI genuinely need administrator rights. Onboarding requests elevation only for those steps, via OnboardingViewModel.RunElevatedCommandAsync.

Docker Desktop solves the same problem differently: its UI never elevates because privileged work lives in a LocalSystem service and the engine runs unprivileged inside the WSL2 distro. WinContainers runs the service in-process instead, so elevation is currently carried by the app process itself.

Check which sessions exist and which one you are in:

& 'C:\Program Files\WSL\wslc.exe' system session list --verbose
Get-ChildItem "$env:LOCALAPPDATA\wslc\sessions"

Known failure mode: if a session directory contains a swap.vhdx but no storage.vhdx — typically after an interrupted first run — wslc in that elevation level fails with Cannot use ... as session storage because the directory is not empty (E_INVALIDARG). Removing the stale directory lets WSLC recreate the session.

When running WinContainers inside a Hyper-V virtual machine, enable nested virtualization on the Hyper-V host:

Set-VMProcessor -VMName "yourVM" -ExposeVirtualizationExtensions $true

Download

Download the latest installer or portable ZIP from GitHub Releases.

The installed application lives under %LOCALAPPDATA%\WinContainers. Portable builds can be extracted to any folder.

How-to Guides

Build From Source

dotnet build WinContainers.slnx -c Debug --nologo -v q
dotnet test tests/WinContainers.Tests.Unit/WinContainers.Tests.Unit.csproj -c Debug --nologo -v q

Publish a self-contained Windows build:

dotnet publish src/WinContainers.App/WinContainers.App.csproj `
  -c Debug -r win-x64 --self-contained `
  -p:PublishTrimmed=false -o publish/WinContainers --nologo -v q

Runtime architecture

WinContainers is built around a WSLC-only runtime contract instead of a second container engine. The app layer, service layer, and runtime layer intentionally stay separate so that command generation, parsing, validation, and persistence remain explicit and testable.

flowchart TD
    A[WinContainers.App UI] --> B[ServiceHost / API]
    B --> C[WslcDriver]
    C --> D[wslc.exe]
    D --> E[JSON/text output]
    E --> F[WslcContainerParser]
    E --> G[WslcResourceParser]
    B --> H[ContainerAccessService]
    H --> I[ContainerConfigStore]
    I --> J[PortBindingConverter]
    F --> K[Container/image models]
    G --> L[Volume/network models]
    J --> M[Normalized publish ports]
    C --> N[WslcCommands]
    N --> D

    O[Unit + Integration tests] --> F
    O --> G
    O --> J
    O --> N
    O --> C
Loading

Repository boundaries

src/
├── BuildTasks/               # MSBuild task used during build
├── WinContainers.AI/         # AI assistant + providers
├── WinContainers.App/        # WinUI app host + UX
├── WinContainers.Core/       # shared commands and models
├── WinContainers.Runtime/    # WSLC execution, parsing, config, access changes
├── WinContainers.Service/    # API and MCP service endpoints
│   └── Host/                # app host and service bootstrap

tests/
├── WinContainers.Tests.Unit/
├── WinContainers.Tests.Integration/
├── WinContainers.Tests.Playwright/
└── WinContainers.Tests.Ui/

Why this matters

  • WslcCommands is the canonical command builder; it turns app intent into WSLC arguments and is covered by contract tests.
  • WslcContainerParser handles container and image JSON/text output by turning raw WSLC payloads into the app’s model objects.
  • WslcResourceParser focuses on volume and network resources, including JSON-array and text-fallback parsing for those specific resource lists.
  • PortBindingConverter validates and normalizes published port mappings, including local-only vs LAN-enabled binding behavior.
  • ContainerAccessService re-creates containers when access policy changes by stopping, removing, re-running, and persisting the updated configuration.
  • WslcDriver owns process execution, timeout boundaries, temp file cleanup, and interaction with the wslc.exe process.

This architecture is intentionally narrow: container operations are WSLC-only, and the tests verify the runtime contracts that the rest of the app depends on.

MCP Server

WinContainers exposes a built-in Model Context Protocol (MCP) server so that AI coding assistants (GitHub Copilot, Cursor, Claude, etc.) can manage containers, images, volumes, and networks directly from the editor.

Endpoint

The MCP server runs on http://localhost:5123/mcp (stateful Streamable HTTP transport) as part of the in-process Kestrel service that starts with the app.

The port and token can be overridden with environment variables:

Variable Default Purpose
WINCONTAINERS_SERVICE_PORT 5123 Port the service listens on
WINCONTAINERS_SERVICE_TOKEN (none) ****** required for remote connections
WINCONTAINERS_MCP_ENABLED (unset) Set to 0 or false to start with the MCP server disabled
WINCONTAINERS_MCP_DESTRUCTIVE_CONFIRMATION_ENABLED (unset) Set to 0 or false only for explicit automation bypass of human approval
WINCONTAINERS_ALLOW_REMOTE_API (unset) Set to 0 or false to start with remote API access blocked

When no token is set the service only accepts loopback connections. When a token is set it also accepts connections from other hosts and requires `Authorization: ******

On/Off Controls

The app Settings page provides live toggles (persisted across restarts):

Setting Effect
MCP server When off, /mcp returns 404 for all clients. The in-app AI chat is not affected.
MCP request logging When on, MCP activity (methods, tool calls, and their results) is written to the Output window.
Destructive confirmation When on, destructive MCP tools request an in-request human Allow/Deny elicitation. Default is true.
Allow remote API access When off, non-loopback /api requests return 403. Localhost requests always work.

The environment variables above apply only at startup and are useful for tests or automation; the Settings toggles are the live source of truth. /api/health reports the current state in the mcpEnabled and apiRemoteAccessEnabled fields.

Destructive tool confirmation

When McpDestructiveConfirmationEnabled is on (default), each destructive tool requests an in-request MCP elicitation with Allow/Deny choices before it executes. The action proceeds only when the client returns Action: "accept" and Content["Allow"] == "allow". Clients that do not support elicitation, cancellations, transport errors, and any malformed response fail closed. Approval prompts contain only safe action, target, and session information; environment values, tar data, and full mount details are never shown. Disabling the setting preserves the explicit automation bypass, but DB-special confirmDestructive guard rails remain enforced.

Connecting an AI Client

Add the server to your AI client's MCP configuration. A ready-made .github/copilot-mcp.json is included in this repository for GitHub Copilot:

{
  "mcpServers": {
    "wincontainer": {
      "description": "Wincontainer container management via wslc. Destructive tools require in-request MCP elicitation with a real human Allow/Deny decision; unsupported clients and failed elicitation fail closed.",
      "url": "http://localhost:5123/mcp",
      "headers": {
        "Authorization": "******"
      }
    }
  }
}

Omit the headers block when connecting from localhost without a token configured.

Deployment skill

This repository includes a reusable Copilot skill for Wincontainer deployment: deploying-to-wincontainer. It covers the elevated WSLC session, image build and export, MCP tar loading, the chunked upload workflow, limits, and verification. AI clients that support repository skills can use it when working in a Wincontainer project.

Available Tools

MCP tool names are snake_case. Destructive tools require an in-request human Allow/Deny elicitation.

Tool Description
list_containers List all containers
inspect_container Get detailed container configuration and status
run_container Run a new container from an image, optionally attached to a named network, with volumes/env/command overrides
start_container Start a stopped container
stop_container Stop a running container
remove_container Delete a container — requires in-request human Allow/Deny elicitation (pass force to remove a running container)
exec_command Execute a command inside a running container
get_container_logs Retrieve recent container logs
pull_image Pull an image from a registry
list_images List downloaded images
inspect_image Get detailed image metadata
remove_image Delete an image — requires in-request human Allow/Deny elicitation
load_image Load a container image from a .tar file or base64-encoded tar data. Examples: load_image(tarPath="C:\\images\\app.tar") or load_image(tarData="<base64 tar data>"). Exactly one of tarPath or tarData is required. Only paths ending with .tar are accepted. When using tarPath, the path is read by the Wincontainer host (not the MCP client machine). Base64 tarData is limited to 512 MB after decoding.
start_image_upload Start a chunked image upload and return the upload ID
upload_image_chunk Append an ordered chunk to a chunked image upload
finish_image_upload Finish a chunked image upload and load it into WSLC
list_volumes List storage volumes
create_volume Create a volume
inspect_volume Get detailed volume information
remove_volume Delete a volume — requires in-request human Allow/Deny elicitation
list_networks List container networks
create_network Create a network
inspect_network Get detailed network information
remove_network Delete a network — requires in-request human Allow/Deny elicitation
redeploy_web_only Redeploy the web container (stops, removes, and re-creates it) — requires in-request human Allow/Deny elicitation
health_check Check whether the wslc runtime is available and return its version
get_version Get the wslc runtime version

Note: WSLC does not support restart or rename operations, so there is no restart_container or rename_container MCP tool. To restart, stop then start (or remove and re-run).

Container LAN access

Published ports are local-only by default and bind to 127.0.0.1. On the container detail page, use the LAN access toggle to recreate a container with published ports bound to 0.0.0.0, so devices on the local network can reach them. The toggle keeps the image, ports, volumes, environment variables, and network settings. Enabling LAN access requires confirmation; disabling it does not.

The toggle requires saved container creation configuration. Containers created from templates, through MCP, or through the AI Assistant save this configuration for later access changes. MCP saves named-container configuration after WSLC creation and before the optional HTTP health probe. Some images, such as nginx:alpine, do not include wget or curl; for these images the MCP result reports httpHealth: "unavailable" while a running container is still treated as successfully created.

Chunked image upload workflow (new):

  1. start_image_upload() -> returns JSON metadata containing the uploadId property
  2. upload_image_chunk(uploadId, sequence, base64Chunk) — pass the uploadId from that JSON response; send ordered, zero-based sequence chunks; each chunk MUST decode to at most 3 KB
  3. finish_image_upload(uploadId) — pass the same uploadId to finalize and assemble the uploaded chunks; the resulting decoded image data is subject to the same 512 MB total limit

Notes:

  • Chunk size limit: each decoded chunk must be 3 KB or smaller.
  • Total upload limit: the sum of decoded chunks must not exceed 512 MB.
  • Empty uploads are rejected before WSLC is called.
  • Sequence numbering: sequences are zero-based and must be uploaded in increasing order; the server will assemble chunks by sequence.
  • Expiry: an upload that is inactive for more than 15 minutes is expired and its state is discarded.
  • Process-local state: upload state is kept only in the service process and is not persisted across restarts; do not rely on uploads surviving a process restart.

MCP tool names are snake_case: start_image_upload, upload_image_chunk, finish_image_upload. Keep upload payloads as base64-encoded chunk strings when calling the MCP tools.

AI Assistant

WinContainers includes a built-in AI assistant that manages containers, images, volumes, and networks in natural language. It uses the same in-process runtime layer as the MCP tools, so no extra services are needed.

Alpha: The AI Assistant is an early-access feature. Review each proposed action before allowing it, especially actions that remove containers, images, volumes, or networks.

What It Does

  • Answer questions about your containers, images, volumes, and networks.
  • Start, stop, and remove containers on request. To restart a container, it stops and starts it.
  • Pull and remove images, create and remove volumes and networks.
  • Run commands inside a running container.
  • Generate docker-compose files for multi-service setups and save them under Documents\WinContainers\compose.
  • Show each tool action as a step card with the exact command it ran.
  • Ask for confirmation before destructive actions (removing containers, images, volumes, or networks).
  • Use the same WSLC runtime as the main application and MCP server.

Providers

  • OpenAI-compatible endpoint — works with OpenAI, Azure OpenAI, and any compatible gateway. Your API key is protected with DPAPI and stored locally.
  • Local Ollama — fully offline. The app detects a running Ollama server or installs it as a container (ollama/ollama, persistent volume, port 11434) and pulls a default model (qwen2.5:3b) automatically.

First Run

Open the AI Assistant page from the left navigation. On first use, a setup dialog asks you to pick a provider. Choose OpenAI-compatible to enter an endpoint, model, and API key, or choose Local Ollama to detect or install it with one click. You can change these settings later on the Settings page.

Privacy

  • Conversations are stored only on your machine under %LOCALAPPDATA%\WinContainers\chats.
  • Your API key never leaves the machine except when sent to the provider endpoint you configured.
  • With Local Ollama, nothing leaves your machine.

Demo Script

A ready-to-run demo is in docs/demo-ai-assistant.md.

Runtime

WinContainers uses wslc.exe as its container runtime. It does not bundle Docker Desktop or use Docker Desktop binaries. Container commands run through the local WSLC runtime and the app communicates with its in-process local service.

Open Source

WinContainers is free and open source under the MIT License. It is a focused local desktop utility, not a hosted service or paid SaaS product.

Author

Created by Jan Petersen.

About

No description, website, or topics provided.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages