wslcontainers
Ask AI wslc 2.9.4.0

wslc networking: ports, DNS and user-defined networks

Updated 2026-07-27 · 7 min read · wslc public preview

wslc networking (WSL2) is built on Windows HNS, the same Host Networking Service that powers Windows containers. Containers get an IP behind a NAT virtual switch by default, and published ports are mapped straight to Windows localhost with no extra proxy.

Publishing ports

The same -p / --publish flag you know from Docker works unchanged:

wslc run -d -p 8080:80 --name web nginx

This makes the container reachable at http://localhost:8080. TCP and UDP are both supported (-p 53:53/udp). The published port is also reachable from other machines on the LAN when the Windows Firewall allows it — no Docker Desktop port-forwarding quirks.

User-defined networks

Create a network, then attach containers to it. Container names become DNS names:

wslc network create mynet

# start a database
wslc run -d --network mynet --name db -e POSTGRES_PASSWORD=secret postgres:16-alpine

# start an app that reaches the database by DNS name "db"
wslc run -d --network mynet --name app -p 3000:3000 myapp

Containers on different networks are isolated by default. You can connect a running container to additional networks with wslc network connect mynet app2.

What does not work

  • --network host — rejected with exit 1.
  • Overlay / multi-host networking — not available in the preview.
  • Macvlan / IPvlan — not documented in 2.9.4.0.
  • Docker Compose network aliases — wslc has no compose runtime.

Network management commands

TaskCommand
List networkswslc network ls
Create a networkwslc network create <name>
Remove a networkwslc network rm <name>
Connect a containerwslc network connect <net> <container>
Disconnect a containerwslc network disconnect <net> <container>
Inspect a networkwslc network inspect <name>

DNS and hostname

wslc supports --dns, --dns-option, --dns-search, --hostname and --domainname. Container names on user-defined networks resolve via the built-in DNS, so --name db means the app container can reach it at hostname db.

Comparing network models

Featurewslc 2.9.4Docker Desktop
Published ports on localhostYesYes
User-defined bridge networksYesYes
Container-name DNSYesYes
Host networkingNoYes
Overlay / multi-hostNoYes (Swarm)
MacvlanNoYes

Related guides