Docker commands fails (in Windows)

I am trying to use Docker on a windows machine and is hit with every possible issue it seems. My latest one is this: My machine is running but I can't seem to interact with it using the docker commands. If I run a very standard command like:

docker ps

I get an error message like this:

An error occurred trying to connect: Get http://%2F%2F.%2Fpipe%2Fdocker_engine/v
1.23/containers/json: open //./pipe/docker_engine: The system cannot find the file specified.

So apparently some path is all messed up. Do anyone know which path this is and how to fix this?


Solution 1:

Edit (2021) - This answer is for the old Docker Toolbox, not Docker Desktop.

When running docker ps and receiving:

An error occurred trying to connect: Get http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.24/containers/json: open //./pipe/docker_engine: The system cannot find the file specified.

The following environment properties need to be set:

 set DOCKER_CERT_PATH=%USERPROFILE%\.docker\machine\machines\default
 set DOCKER_HOST=tcp://192.168.99.100:2376
 set DOCKER_MACHINE_NAME=default
 set DOCKER_TLS_VERIFY=1

This is assuming the %USERPROFILE%\.docker\machine\machines\default is default path where the cert.pem, key.pem, ca-key.pem, and ca.pem docker files are; the virtual machine name's (created by docker-machine create) is default and Virtual Box DHCP Server's lower bound (found under VirtualBox->File->Preferences->Network->Host-only Networks->hover mouse on VirtualBox Host-Only Ethernet Adapter) is 192.168.99.100 and no other VM is running in VirtualBox.

Solution 2:

Same issue here on Win 7. Solution:

In the Docker Quickstart window, at the $ prompt run the below line:

your_user@your_machine MINGW64 ~

$ eval $("C:\Program Files\Docker Toolbox\docker-machine.exe" env default)

Then, you'll be able to run "docker run hello-world".

Solution 3:

I run into this problem when using docker-machine and I haven't run the docker-machine env command after rebooting. I'm not sure how to do this in cmd.exe, but if you're using powershell try issuing this command:

docker-machine env --shell=powershell | Invoke-Expression