You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何通过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.

Check Docker Status in PowerShell

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 name DockerDesktopService. 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. Try docker ps or docker 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.


Check Docker Status in Command Prompt (CMD)

For CMD, we'll use Windows service tools and the Docker CLI:

  • Query the Docker Desktop Service
    Use the sc query command 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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.13 09:13:36