I want to write a PowerShell script that will create a number of running docker containers on boot of the machine. The problem I'm running into is that despite the com.docker.service
service running, the backend for Docker Desktop (I presume WSL2) is still getting ready.
I can manually recreate this behaviour by running docker version
or similar when the system is starting. It will show:
error during connect: In the default daemon configuration on Windows, the docker client must be run with elevated privileges to connect.: Get "http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.24/containers/json": open //./pipe/docker_engine: The system cannot find the file specified.
However after a couple of minutes (once the backend has come up) then the command will start working:
Client:
Cloud integration: v1.0.22
Version: 20.10.11
API version: 1.41
Go version: go1.16.10
Git commit: dea9396
Built: Thu Nov 18 00:42:51 2021
OS/Arch: windows/amd64
Context: default
Experimental: true
How can I reliably wait for Docker Desktop to be ready before trying to start containers? I suspect the solution might be waiting for the pipe file or similar rather than a service.