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.