Docker: An error occurred trying to connect

I got same error on Windows 7 inside Docker Terminal. So I had to do the following. In case somebody like me is searching for this.

$ docker-machine rm default
$ docker-machine create --driver virtualbox default

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

If you want to use PowerShell (in Windows 7) instead of Docker Quickstart Terminal then enter following commands step by step in your powershell terminal:

NOTE: You must have to start Docker Quickstart Terminal first before performing below operations

docker-machine.exe env --shell powershell it will display below commands on terminal:

$Env:DOCKER_TLS_VERIFY = "1"
$Env:DOCKER_HOST = "tcp://192.168.99.100:2376"
$Env:DOCKER_CERT_PATH = "C:\Users\pratikpat\.docker\machine\machines\default"
$Env:DOCKER_MACHINE_NAME = "default"
# Run this command to configure your shell:
# & "C:\Program Files\Docker Toolbox\docker-machine.exe" env --shell powershell | Invoke-Expression

Execute last displayed command to configure your shell:

& "C:\Program Files\Docker Toolbox\docker-machine.exe" env --shell powershell | Invoke-Expression