Docker: An error occurred trying to connect

Janshair Khan picture Janshair Khan · Jan 28, 2016 · Viewed 12.9k times · Source

Installed Docker on Windows with 2 additional installs, Oracle VM VirualBox and Kitematic. I've disabled Hyper-V in my Windows 10 PC. Now the problem is I can't download any Docker images from DockerHub, not even I can run the command as

Docker info

At both ends it shows the following error.

An error occurred trying to connect: Get http://localhost:2375/v1.21/info: dial tcp 127.0.0.1:2375: ConnectEx tcp: No connection could be made because the target machine actively refused it.

If I run it in Docker QuickStart Terminal it works, but not working in PowerShell or in MSBuild.

Answer

Arseny Kovalchuk picture Arseny Kovalchuk · Feb 9, 2016

If you are using windows command prompt instead of Docker QuickStart Terminal see official docs you should make following steps (assuming your docker machine has the name default):

  1. docker-machine start default or create new one
  2. docker-machine lswill show you your machine running
  3. docker-machine env --shell cmd default and you'll see something like

    SET DOCKER_TLS_VERIFY=1
    SET DOCKER_HOST=tcp://192.168.99.100:2376
    SET DOCKER_CERT_PATH=C:\Users\Arseny\.docker\machine\machines\default
    SET DOCKER_MACHINE_NAME=default
    REM Run this command to configure your shell:
    REM     FOR /f "tokens=*" %i IN ('docker-machine env --shell cmd default') DO %i
    
  4. Run FOR /f "tokens=*" %i IN ('docker-machine env --shell cmd default') DO %i
  5. Enjoy