moby: Trying to connect to Docker API for shell commands throws error
The issue: When running any Docker command, the error below is printed, and most commands don’t even run
Output of docker version
:
Client:
Version: 1.11.0
API version: 1.23
Go version: go1.5.4
Git commit: 4dc5990
Built: Wed Apr 13 18:13:28 2016
OS/Arch: windows/amd64
An error occurred trying to connect: Get http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.23/version: open //./pipe/docker_engine: The system cannot find the file specified.
Output of docker info
:
An error occurred trying to connect: Get http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.23/info: open //./pipe/docker_engine: The system cannot find the file specified.
Additional environment details (AWS, VirtualBox, physical, etc.): I’m in Windows 10 with Toolbox 1.11.0 with Kitematic installed
Steps to reproduce the issue:
- Install Docker Toolbox
- Run any docker command?
Describe the results you received:
The exact error listed in docker info
here, and most commands such as docker ps
don’t work
Additional information you deem important (e.g. issue happens only occasionally): This message gets pasted to the end of any Docker command I run, and only certain commands even remotely work
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 50
- Comments: 41 (13 by maintainers)
This is likely due to either the Virtual Machine not being started (try
docker-machine start default
), or the environment variables not being set in your shell (docker-machine env default
should print the instructions for doing so). However, this should be reported in the docker-toolbox issue tracker, or check if there’s an existing issue; https://github.com/docker/toolbox/issues?q=is%3Aissue+“trying+to+connect”+sort%3Acomments-desc+is%3AopenYou may be interested in the Docker for Windows beta, which resolves most of these issues; https://blog.docker.com/2016/03/docker-for-mac-windows-beta/. You can register for that beta through https://beta.docker.com.
I had the same issue after I rebooted Windows once (before reboot docker worked fine). The advice to follow
docker-machine env default
instructions worked for me.This is how it was:
i.e.
@FOR /f "tokens=*" %i IN ('docker-machine.exe env --shell cmd') DO @%i
Same issue but gone when changed from powershell to cmd but now it’s stuck at docker run command:
The machine is running, I’ve even got containers running in Kitematic, its just that the shell commands won’t work. I’m fairly sure this is a Docker issue not something with Toolbox
This is what I did… and worked fine
If it’s running, then I suspect the environment variables aren’t set; did you try
docker-machine env default
, and followed the instructions?You have to run this: @FOR /f “tokens=*” %i IN (‘docker-machine env docker1’) DO @%i
I got the same error when I tried to launch
docker ps
, but the rest of the commands work properly. After some time we found that there was any active docker-machine.If you launch
docker-machine ls
command and you see that they are running (I have 2) but any of them is the active, then, you must launch the next one to activate the default machine.eval $(docker-machine env default)
This fixes the issue.
You set the environment variables following the instructions of
docker-machine env --shell cmd
?I just ran into this issue. A google search led me to this page, and I ran the commands in
docker-machine env default
and things worked out well. This was the first time using the product following the quicksart directions here. It creates friction when starting with the product, and it would be nice if there were a more user friendly error message explaining what to do.👍 Glad to hear it’s working now all
It was cmd, but it was probably an earlier version of docker tools too. The latest doesn’t output the quotes anymore. Just wanted to mention the source of that error, in case anyone sees it again.
To avoid runin that command each time try on your windows git bash CLI:
echo 'eval $("C:\Program Files\Docker Toolbox\docker-machine.exe" env default)' >> .bash_profile
This will append that string at the end of .bash_profile. Open a new instance to changes take effect.I got the same issue then I realized about the invoke-expression missing at the end of the command:
docker-machine env --shell powershell default | Invoke-Expression
Without the invoke, the variables only gonna be printed in your shell.
Hope this can help anyone else.