Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix Now×
Skip to content
Redmond desk4 min

How to Map a Docker Container PID to Its Host PID on Windows

Docker Desktop’s WSL2 backend is the Linux host you need when mapping a container PID on Windows. Here’s how to inspect it and verify IDs with NSpid.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

On Docker Desktop with the WSL2 backend, a container PID does not map directly to a number in the ordinary Windows process list. The container runs in a Linux PID namespace inside Docker Desktop’s WSL2 environment. To find the corresponding host-side process, inspect that Linux environment—typically with wsl -d docker-desktop and ps -ef—or use a temporary diagnostic container joined to the host PID namespace.

Why the numbers are different

Linux PID namespaces give a process a separate numeric identity in each namespace. A process can therefore be PID 1 inside a container while having a larger PID in the parent namespace. PID 1 is meaningful only within the namespace where you read it.

As an Amazon Associate I earn from qualifying purchases.

Docker Desktop on Windows adds another boundary: Linux containers run in a WSL2-based backend rather than as ordinary native Windows processes. The practical “host PID” for a Linux container is consequently the PID in that backend’s Linux namespace. Windows tools may show virtualization or backend processes instead of a simple one-to-one entry for every container process.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use the Docker Desktop WSL2 environment

The Linux Foundation forum procedure for this setup is to enter Docker Desktop’s internal WSL distribution and inspect its process table:

#1 Best Overall
  1. Open PowerShell or Windows Terminal.
  2. Run wsl -d docker-desktop.
  3. Inside that shell, run ps -ef.

The resulting list can include the containerd-shim-runc-v2 process and shell processes belonging to running containers. Match the process by its command line, container workload, or parent-child relationship rather than assuming that the container’s PID number will be unchanged.

Docker Desktop’s internal distributions are special-purpose components. Their names, accessibility, and process layout can vary between Docker Desktop and WSL releases, so a distribution that is present on one installation may not be exposed in exactly the same way on another.

Compare the namespaces directly

Read the PID inside the container

Open a shell in the target container and inspect its process list:

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Dell Latitude 5420 14" FHD Business Laptop Computer, Intel Quad-Core i5-1145G7, 16GB DDR4 RAM, 256GB SSD, Camera, HDMI, Windows 11 Pro (Renewed)
  • 256 GB SSD of storage.
  • Multitasking is easy with 16GB of RAM
  • Equipped with a blazing fast Core i5 2.00 GHz processor.
docker exec -it <container_name_or_id> sh
ps -ef

For the container’s init process, inspect its status file:

cat /proc/1/status

On Linux, the NSpid line records the process IDs assigned in nested PID namespaces. A process may appear as PID 1 in the container and as a larger value in the parent namespace. The exact values depend on the running container and the namespace from which the file is read.

Read the mapping from the appropriate Linux host namespace

After identifying the host-side Linux PID, inspect its status file from that host namespace:

Rank #3
15.6 Inch Laptop Computer, N4020, 4GB DDR4 RAM, 128GB eMMC,with Windows 11
  • EFFORTLESS EVERYDAY PERFORMANCE: Powered by Intel Celeron N4020 processor and Windows 11 Home system, delivering reliable, low-power efficiency for daily tasks like document editing, email, online classes, and web browsing
  • 15.6-INCH FULL HD DISPLAY: Enjoy immersive visuals on the 15.6" FHD (1920x1080) anti-glare screen with micro-edge bezels. Delivers clear details and comfortable viewing for long study sessions, working on spreadsheets, and video playback
  • RESPONSIVE MULTITASKING & STORAGE: Built with 4GB LPDDR4 RAM and 128GB eMMC storage for smooth daily essential use. Expand your storage by up to 1TB via the integrated TF card slot to easily store movies, photos, and working files
  • ADVANCED CONNECTIVITY: Outfitted with 2x Full-Featured Type-C ports for data transfer, fast charging, and dual-monitor output, alongside 2x USB 3.2 Gen1 ports and a 3.5mm audio jack for complete peripheral compatibility
  • LIGHTWEIGHT & SILENT OPERATION: Slim and portable for effortless travel or commuting. Features a 1MP HD webcam for remote meetings, 38Wh battery with 45W Type-C fast charging, and a fanless silent design for peaceful work environments.
cat /proc/<host-pid>/status

Look for NSpid. The line lists the IDs that the same process has in the nested namespaces visible from that context. This is the reliable way to verify a cross-namespace relationship; comparing two ps outputs by number alone is not.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Temporary diagnostic container with host PID visibility

If entering the backend distribution is inconvenient, the forum discussion gives this diagnostic command:

docker run -it --rm --pid=host --privileged --net host ubuntu bash

Inside the temporary Ubuntu shell, run:

ps -ef

--pid=host places the diagnostic container in the host PID namespace, while --net host shares the host network namespace. --privileged grants broad additional capabilities. This combination is for short-lived troubleshooting only: it changes normal container isolation and should not be used as a default runtime configuration. Remove the shell when finished; the --rm option deletes the temporary container.

Rank #4
15.6 Inch Win 11 Laptop Computer, N4020, 4GB DDR4 RAM, 128GB Storage
  • WINDOWS 11 | STABLE PERFORMANCE: Powered by Intel Celeron N4020 processor and Windows 11 system, this laptop delivers stable performance for everyday computing tasks. It supports web browsing, online learning, document editing, email communication, and basic office work with optimized power efficiency, providing a practical and reliable experience for essential daily use for daily use.
  • 15.6” FHD IPS DISPLAY: Features a 15.6-inch Full HD IPS display with narrow bezels, offering wider viewing angles and clearer image details compared to standard panels. The improved screen-to-body ratio enhances visual experience for study, reading, document work, and video playback, making it suitable for both productivity and entertainment use.
  • 4GB DDR4 + 128GB eMMC STORAGE: Equipped with 4GB DDR4 memory and 128GB eMMC storage for everyday basics such as browsing, documents, email, and online learning platforms. The built-in TF card slot supports storage expansion up to 1TB, giving you more flexibility for files, photos, videos, and daily documents. TF card not included.
  • CONNECTIVITY & PORTS: Includes 1× TF card slot, 2× USB 3.2 Gen1 ports, and 2× full-featured Type-C ports (USB 3.2 Gen1). The Type-C ports support data transfer, charging, and video output, enabling flexible connection with external devices such as monitors, storage, and peripherals for daily work and study use.
  • LIGHTWEIGHT DESIGN | ONLINE COMMUNICATION: Designed with a slim, portable profile, this laptop is easy to carry for school, commuting, and travel. A built-in 1MP front camera supports online classes, video meetings, remote communication, and everyday conferencing. The 3300mAh battery works with the low-power system design to support practical daily use, while thermal optimization helps maintain quieter operation during extended tasks.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

What each environment can show

View PID you see What it represents Use for mapping
Normal container Container-namespace PID The process identity visible inside the container Start here; record the command and PID
WSL2/Docker backend Parent Linux-namespace PID The Linux host process running the container workload Use ps -ef to find the shim and related processes
Diagnostic container with --pid=host Host PID namespace PID A direct view of host-side Linux processes Useful for temporary inspection
Native Windows process tools Windows or virtualization-process IDs Backend components rather than a guaranteed per-container Linux PID Do not expect a one-to-one numeric match

A practical mapping workflow

  1. Record the process and PID inside the container with docker exec and ps -ef, or inspect /proc/<pid>/status.
  2. Enter the Docker Desktop backend with wsl -d docker-desktop, when that distribution is available.
  3. Run ps -ef and locate the matching command, shell, or containerd-shim-runc-v2 process.
  4. Read /proc/<host-pid>/status and compare its NSpid values with the container-side PID.
  5. If the backend process table is not accessible, start the temporary diagnostic container with --pid=host, then repeat the process and NSpid checks.

Common mistakes

  • Looking only in Task Manager: Windows may expose the WSL2 or virtualization layer, not each Linux container process.
  • Assuming PID 1 is global: PID 1 is the first process in that PID namespace, not necessarily the first process on the Linux host.
  • Using host namespaces permanently: --pid=host, --net host, and --privileged reduce isolation and should remain temporary diagnostics.
  • Reading NSpid from the wrong namespace: The useful mapping appears only when the status file is inspected from a namespace that can see the relevant process hierarchy.

What to expect on different installations

The procedure applies to Docker Desktop using WSL2, but Docker Desktop and WSL releases can change internal distribution names and visibility. The Linux Foundation discussion documenting wsl -d docker-desktop dates from June 2022; treat that command as an installation-dependent entry point rather than a promise that every current release exposes the same shell. The namespace principle and the meaning of NSpid remain the basis for interpreting the result.

The Bottom Line

For Docker Desktop on Windows, map a container PID to the Linux PID in Docker’s WSL2 backend—not to a number you expect to find directly in the Windows process list. Use wsl -d docker-desktop with ps -ef, verify the relationship through /proc/<pid>/status and NSpid, and reserve --pid=host diagnostics for controlled troubleshooting.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Quick Recap

Bestseller No. 1
HP 14' HD Laptop, Windows 11, Intel Celeron Dual-Core Processor Up to 2.60GHz, 4GB RAM, 64GB SSD, Webcam, Dale Pink (Renewed)
HP 14" HD Laptop, Windows 11, Intel Celeron Dual-Core Processor Up to 2.60GHz, 4GB RAM, 64GB SSD, Webcam, Dale Pink (Renewed)
14" diagonal, 1366x768 resolution, HD BrightView LED, Glossy NON-TOUCH Display
$245.99
Bestseller No. 2
Dell Latitude 5420 14' FHD Business Laptop Computer, Intel Quad-Core i5-1145G7, 16GB DDR4 RAM, 256GB SSD, Camera, HDMI, Windows 11 Pro (Renewed)
Dell Latitude 5420 14" FHD Business Laptop Computer, Intel Quad-Core i5-1145G7, 16GB DDR4 RAM, 256GB SSD, Camera, HDMI, Windows 11 Pro (Renewed)
256 GB SSD of storage.; Multitasking is easy with 16GB of RAM; Equipped with a blazing fast Core i5 2.00 GHz processor.
$285.00

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.