0

I see the similar post, but they are for Docker on Linux.

I am using Docker Desktop for Windows 10.

This Windows 10 machine that has Docker running on is setup to auto reboot. There are other scripts will be run after Docker startup. The Windows and Docker startup process takes a bit time to complete. Is there a way to monitor docker services and all needed containers till they are up and running? So rest of scripts will continuously run without sending error message because Docker is not ready yet.

PowerShell preferred.

KyleMit
  • 30,350
  • 66
  • 462
  • 664
Root Loop
  • 3,004
  • 9
  • 46
  • 72

2 Answers2

1

Just a thought:

  • When docker in the process of start or not start:

    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
    
  • When docker finish start & in run:

    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
    

You could write a script to poll the status of docker version to assure docker ready.

atline
  • 28,355
  • 16
  • 77
  • 113
0

The docker version may be a way to do it, but would require parsing text and at a future date if that text changes then your script will also have to be maintained and updated.

Another approach is to just simply watch for processes using Get-Process. When Docker is not running you will/should only see the com.docker.service running. Once Docker for Windows has started up completely you will see an additional 3-4 other processes. One in particular that tends to be there once Docker is fully running is the com.docker.proxy service.

So once this command returns the process you would know Docker for Windows is up and running:

Get-Process 'com.docker.proxy'