How to check if Docker is running on Windows?
Solution 1
Try running either of these commands on Powershell or cmd, if docker is installed, you should get a error free response:
docker --version
OR
docker-compose --version
OR
docker ps
Solution 2
Afford two methods:
-
docker version
This method works both for
cmd
&powershell
, but if forcmd
, you need to useecho %errorlevel%
to check the result.If
docker daemon
is running, it will be like next:PS C:\> docker version Client: Docker Engine - Community Version: 18.09.2 API version: 1.39 Go version: go1.10.8 Git commit: 6247962 Built: Sun Feb 10 04:12:31 2019 OS/Arch: windows/amd64 Experimental: false Server: Docker Engine - Community Engine: Version: 18.09.2 API version: 1.39 (minimum version 1.12) Go version: go1.10.6 Git commit: 6247962 Built: Sun Feb 10 04:13:06 2019 OS/Arch: linux/amd64 Experimental: false PS C:\> echo $? True
If
docker daemon
not running, it will be next:PS C:\> docker version Client: Docker Engine - Community Version: 18.09.2 API version: 1.39 Go version: go1.10.8 Git commit: 6247962 Built: Sun Feb 10 04:12:31 2019 OS/Arch: windows/amd64 Experimental: false Error response from daemon: An invalid argument was supplied. PS C:\> echo $? False
-
Get-Process
:This method just works for
powershell
.If
docker daemon
is running, it will be next:PS C:\> Get-Process 'com.docker.proxy' Handles NPM(K) PM(K) WS(K) CPU(s) Id SI ProcessName ------- ------ ----- ----- ------ -- -- ----------- 205 10 11416 18860 0.13 12620 2 com.docker.proxy PS C:\> echo $? True
If
docker daemon
is not running, it will be next:PS C:\> Get-Process 'com.docker.proxy' Get-Process : Cannot find a process with the name "com.docker.proxy". Verify the process name and call the cmdlet again. At line:1 char:1 + Get-Process 'com.docker.proxy' + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (com.docker.proxy:String) [Get-Process], ProcessCommandException + FullyQualifiedErrorId : NoProcessFoundForGivenName,Microsoft.PowerShell.Commands.GetProcessCommand PS C:\> echo $? False
Solution 3
docker info
- The operating-system independent way to check whether Docker is running is to ask Docker, using the docker info command. This option will work for both Windows and Linux distributions.
- If Docker is running when you will get result as shown below, otherwise you will get an error message:
C:\Users\himanshu.agrawal>docker info Client: Debug Mode: false Plugins: scan: Docker Scan (Docker Inc., v0.3.4) Server: Containers: 1 Running: 0 Paused: 0 Stopped: 1 Images: 2 Server Version: 19.03.13 Storage Driver: overlay2 Backing Filesystem: extfs Supports d_type: true Native Overlay Diff: true Logging Driver: json-file Cgroup Driver: cgroupfs Plugins: Volume: local Network: bridge host ipvlan macvlan null overlay Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog Swarm: inactive Runtimes: runc Default Runtime: runc Init Binary: docker-init containerd version: 8fba4e9a7d01810a393d5d25a3621dc101981175 runc version: dc9208a3303feef5b3839f4323d9beb36df0a9dd init version: fec3683 Security Options: seccomp Profile: default Kernel Version: 5.4.39-linuxkit Operating System: Docker Desktop OSType: linux Architecture: x86_64 CPUs: 2 Total Memory: 1.915GiB Name: docker-desktop ID: HHIB:HQRB:7VBA:LBUY:HKVJ:LFZ3:FSWZ:4ARP:74ZB:TIWO:WTMG:LHZH Docker Root Dir: /var/lib/docker Debug Mode: false Registry: https://index.docker.io/v1/ Labels: Experimental: false Insecure Registries: 127.0.0.0/8 Live Restore Enabled: false Product License: Community Engine
Get-Process 'com.docker.proxy'
- This option can only be used with Windows Power Shell (just Power Shell, not even with CMD). If Docker is running you will get output as below, otherwise you will get an error message:
PS C:\Users\himanshu.agrawal> Get-Process 'com.docker.proxy' Handles NPM(K) PM(K) WS(K) CPU(s) Id SI ProcessName ------- ------ ----- ----- ------ -- -- ----------- 178 15 22984 25172 0.77 14224 1 com.docker.proxy
Other options - Linux specific
- You can also use operating system utilities, such as
sudo systemctl is-active docker
orsudo status docker
orsudo service docker status
, or checking the service status using Windows utilities. - Finally, you can check in the process list for the "dockerd" process,
using commands like
ps
ortop
.
Solution 4
If using wsl2 on Windows, you can use:
wsl -l -v
Output will be something like the below:
NAME STATE VERSION
* Ubuntu Stopped 1
docker-desktop Running 2
docker-desktop-data Running 2
Solution 5
I had the same issue while writing some scripts to work with Docker containers on Windows.
The answers given were not applicable for me because they just took too much time. I assumed that "is Docker running on Windows" also meant that the default
VM was running. So instead the other answers I checked for the Docker default
machine IP 192.168.99.100
which should normally be running when Docker is on. I then just pinged it:
ping -n <numberOfPings> -w <waitingTimeInMilliSeconds> 192.168.99.100
#Example:
ping -n 1 -w 1000 192.168.99.100
I found when Docker is running I normally get a response in less than 1ms which means the check is quite fast. This also means that it should be very robust to wait for even less than 1000ms if the Docker default
machine is not running.
Bub Espinja
Updated on February 05, 2022Comments
-
Bub Espinja about 2 years
I'd like to know how to check if Docker is running on Windows by means of the command line (cmd or powershell).
Although, I've found several posts indicating the solution to this, they are for Linux environments:
How to check if docker is running or not
How to check if docker daemon is running?
I couldn't get the answer for Windows systems.
-
Bub Espinja over 4 yearsInteresting approach!
-
Steven about 3 yearsGet-Process will still work after it has been started but before it's ready. If you want to know when Docker is ready, not just started, docker info will only return a valid response when docker is started and also up and ready.
-
KargWare about 3 yearsA Hint:
docker --version
will show show just the version. Butdocker version
(without dashes) will show much more details. -
Noah Allen about 3 yearsI would recommend
docker ps
ordocker info
for cross-platform use. Unfortunately,docker --version
completes successfully on other platforms like macOS even when Docker isn't running. -
Pierre over 2 years"docker ps" (checks that docker is there AND running) is better than "docker --version" (only checks that docker is installed). The "docker ps" check works on Mac, Windows, and Ubuntu (probably works all Linux flavors but I use Ubuntu so that's what I'll report on)