如何通过cmd/PowerShell命令行检查Windows系统中Docker是否运行?
Hey there, I totally get the frustration when Linux-focused solutions don't translate to Windows. Let's walk through how to check if Docker is running on Windows using either PowerShell or Command Prompt (CMD) — these methods work for Docker Desktop, which is the standard setup for Windows users.
PowerShell gives you a couple of reliable ways to verify Docker's status:
- Check the Docker Desktop Service
Docker Desktop runs as a Windows service under the nameDockerDesktopService. You can get its status directly with:
Get-Service DockerDesktopService
Look for the Status column — if it shows Running, Docker is active.
For a more automated, user-friendly check, wrap it in a simple script:
$dockerService = Get-Service DockerDesktopService if ($dockerService.Status -eq 'Running') { Write-Host "✅ Docker is running" -ForegroundColor Green } else { Write-Host "❌ Docker is not running" -ForegroundColor Red }
- Use the Docker CLI directly
If the Docker CLI is in your system PATH, you can run a quick command that will fail explicitly if Docker isn't running. Trydocker psordocker info:
# Using docker ps to check connectivity if (docker ps 2>&1 | Select-String -Pattern "error during connect") { Write-Host "❌ Docker is not running" -ForegroundColor Red } else { Write-Host "✅ Docker is running" -ForegroundColor Green }
The 2>&1 redirects error output to the main stream, so we can catch the common "error during connect" message that pops up when Docker's daemon isn't active.
For CMD, we'll use Windows service tools and the Docker CLI:
- Query the Docker Desktop Service
Use thesc querycommand to inspect the service state:
sc query DockerDesktopService
Scroll through the output — look for STATE : 4 RUNNING to confirm Docker is up and running.
To automate this in a batch script:
@echo off sc query DockerDesktopService | findstr /i "RUNNING" if %errorlevel% equ 0 ( echo ✅ Docker is running ) else ( echo ❌ Docker is not running )
The findstr command searches for the "RUNNING" string, and %errorlevel% will be 0 if it's found (meaning the service is active).
- Use the Docker CLI
Just like in PowerShell, running a Docker CLI command will return an error code if Docker isn't running. You can use this to create a clean check:
@echo off docker ps >nul 2>&1 if %errorlevel% equ 0 ( echo ✅ Docker is running ) else ( echo ❌ Docker is not running )
The >nul 2>&1 hides all output (both standard and error), so we only see our custom status message based on the error code.
Note: These methods work for Docker Desktop (the most common Windows Docker setup), whether you're using the Windows container backend or WSL2 backend — Docker Desktop manages the necessary services in both cases.
内容的提问来源于stack exchange,提问作者Bub Espinja

