Docker command line fails to connect

Docker Desktop Version:4.16.3
OS: Windows 10 Enterprise 21H2

My docker install has been working fine for years, now the command line it fails to connect, some examples below.

docker version
error during connect: Get “http://172.31.0.2:2376/v1.24/version”: dial tcp 172.31.0.2:2376: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond…
Client:
Cloud integration: v1.0.29
Version: 20.10.22
API version: 1.41
Go version: go1.18.9
Git commit: 3a2c30b
Built: Thu Dec 15 22:36:18 2022
OS/Arch: windows/amd64
Context: tmplinux
Experimental: true

docker run hello-world
docker: error during connect: Post “http://172.31.0.2:2376/v1.24/containers/create”: dial tcp 172.31.0.2:2376: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.

I cant see anything listening on port 2376 using netstat. I can however use Docker Desktop to start and get a shell to existing container and I can also do this from visual code with the docker extension installed, it just seems to be the command line client that fails.

I’ve uninstalled and upgraded to the latest version and still no joy.

This is not the context that Docker Desktop uses. It looks like you have a custom context configured to use a TCP socket.

You can switch back to Docker Desktop this way:

docker context use desktop-linux

The context name could be different so if it doesn’t work, try the following command to list the contexts:

docker context ls