Docker commands fails (in Windows) [closed] - docker

Closed. This question is not about programming or software development. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 3 months ago.
Improve this question
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?

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.

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".

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

Make sure Hyper-V is up and running:
open elevated command prompt
type bcdedit /set hypervisorlaunchtype auto
reboot
run "Docker for Windows"

I had to deal with the same issue on Windows.
To solve it:
Create a docker machine (only if you have not got one)
docker-machine create default
Get the ENV vars which the docker client needs in order to connect to the docker machine (server) [This you will need to do every time or set in your ENV vars]
docker-machine.exe env default
You can either install them manually or run one of the following depending on your shell environment (cmd, bash, power-shell)
docker-machine env --shell=cmd # you need to run it manually
docker-machine env --shell=bash > env-var-commands-tmp && . env-var-commands-tmp && rm env-var-commands-tmp
docker-machine env --shell=powershell | Invoke-Expression

Open cmd with admin rights.
Execute following command
docker-machine env --shell cmd default
you will receive following output
SET DOCKER_TLS_VERIFY=1
SET DOCKER_HOST=tcp://192.168.99.102:2376
SET DOCKER_CERT_PATH=C:\Users\DBashyal.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
Copy the highlighted line and execute on cmd
#FOR /f "tokens=*" %i IN ('docker-machine env --shell cmd default') DO #%i
Execute following command
docker ps

I created a new machine using the below command
docker-machine create --driver=virtualbox vbox-test
Then executed the command
docker-machine env --shell=powershell | Invoke-Expression
Got it Working...

I had a look at all the above answers and none of them worked.
Then I found out that the command has to be run on a linux command line like bash.
so try:
Type the command into the Docker bash terminal VM that comes with the docker toolbox as opposed to the windows cmd
If you have already made sure that your docker has been started

As pointed in other answers you need to set a few environment variables.
The easiest way to do it is:
#FOR /f "tokens=*" %i IN ('docker-machine env --shell cmd') DO #%i
This will run docker-machine env --shell cmd and add those environmental variables.
If you want these variables to be persistent defined them in windows (tutorial).

Right click the Docker icon in the tray a select "Switch to Windows containers...".
You may be prompted to enable the Containers feature. Do so and reboot, again.

To start default host in windows I know three ways given below you can use one of them.
Starting or restarting already created a default machine by the Docker:
docker-machine start default
docker-machine restart default
Now check docker-machine env
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
To create a new machine using the following command:
Windows 10/HyperV:
docker-machine create --driver hyperv default
docker-machine create -d hyperv default
Mac, Linux, windows 7 & 8:
docker-machine create --driver virtualbox default
docker-machine create -d virtualbox default

I had similar issue when I installed Docker CE for Windows Version 17.11.0-ce-rc4-win39 (14244) Channel: edge e557194 on Windows 10.
In Command/cmd windows, when I tried to run commands docker ps, docker version, docker info, the I got error like “error during connect: Get http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.34/version” every time.
To resolved this issue,
I made “Hyper-V” off (Unchecked) from “Turn Windows feature on or off”, which required the OS to be restarted.
And after first restart, I made “Hyper-V” On (Checked), which again required the OS to be restarted.
After second restart, above docker commands started working and giving proper output.
So, turning Hyper-V off and then on resolved this issue for me.

I got the solution from this issue. It not just like Nikesh's answer said SwitchDaemon could fix it directly. I think you should run this command twice to switch your daemon to your previous daemon.
cd "C:\Program Files\Docker\Docker"
./DockerCli.exe -SwitchDaemon
# then check the docker OS/Arch
docker version
# You may see the different OS/Arch
./DockerCli.exe -SwitchDaemon
# then you got your images and containers back
This command is just switch your daemon from your defualt daemon to another daemon(depends on what you set). When you switch to another daemon, the images and containers on the former daemon will disappear(but not deleted).

I have had this issue on a Windows 2016 machine. Happened because the docker service wasn't started. In my case the docker service as failing with the following error
fatal: Error starting daemon: pid file found, ensure docker is not running or delete C:\ProgramData\docker.pid
Deleting the C:\ProgramData\docker.pid file did the trick.

below resolved. i copied answer from another forum
I had this problem after update. After re-installing VB I switched on "VirtualBox NDIS6 Bridged Networking Driver" in properties network connection.
It property switched off default in my case.

Windows 10 Professional
For me the Docker service was running but Docker still needed to be 'started'. That is, I had the setting 'Start Docker when you log in' unchecked in the Docker tray icon.
Prior to finding this out I had gone to the program folder Docker and clicked 'Docker for Windows'. After a short time the message 'Docker is running' was displayed.

For me, this error was resolved after I removed daemon.json file in "%programdata%\docker\config"
The content in my daemon.json is the following:
{
"hosts": ["tcp://0.0.0.0:2375"]
}
I created this manually as part of some testing. But after I restarted the server, I started to get the error in this question.

The error is really troubling. I hope Docker Developers do something about. It took a lot of try and error to get around. Thanks to Stackoverflow and other blogs. In my case, I am using Windows 10 Pro. I settled with DockerToolbox.exe after several failed attempts with Docker for Windows Installer.exe. Then I encountered An error occurred trying to connect: Get http://%2F%2F.%2Fpipe%2Fdocker_engine/v . The followed these steps and the problem got solved.
First, I went to Control Panel -> Turn Windows Features On or Off and unchecked Hyper-V
Next, Open PowerShell as Admin:
docker-machine env --shell=powershell | Invoke-Expression
type bcdedit /set hypervisorlaunchtype auto
Restarted my System. Then I launched "Docker Quickstart Terminal", then I entered this on the shell window.
run "Docker for Windows"
docker run hello-world
I it went well. Then I open Command Prompt
docker run hello-world
It gave the error: Then I entered
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
Most of the suggestions above too are helpful.

I saw this error message after a weekend. My setup was fine before that. My config and connections looked correct. $docker-machine restart default fixed it for me on Windows 7

I was getting this error, while running the command docker-compose up. The problem for me was, the docker service was not running. So I had to run services.msc and start the docker service.

I solved this error by run the {DOCKER_TOOLBOX_INSTALL_PATH}start.sh in bash.

In my case, all above solutions did not resolve. Instead zilurrane response helped.
cd "C:\Program Files\Docker\Docker"
./DockerCli.exe -SwitchDaemon

Switch to Windows Containers
docker info
docker ps
Switch back to Linux containers
docker info
Viola!
The windows switch likely runs the missing configurations that Linux also needs.

I was having similar issue. For me I hadn't logged in to docker from the status bar. What I did was to login to docker from status bar. Once I logged in I was able to run all the commands properly.
Try logging in using your docker id and password maybe that will resolve your issue.

I had the same issue on my Windows 10. Find below what I did to solve it:
After installing Docker, Just restart your PC, run docker application (It may require enabling Hyper-V), then open command line and type:
docker run hello-world
Everything works fine :)

I had this problem. I searched a lot. I checked many things. But in the end, the solution that solved my problem was the following solution.
System Environment:
Windows 10 Professional
Windows engine in Docker
Docker version 20.10.21
Solution
disabled IP6
And
Restarted the service and application

Related

error during connect: This error may indicate that the docker daemon is not running

I am new to Docker and after writing docker version in cmd I got this error,
error during connect: This error may indicate that the docker daemon is not running.: Get "http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.24/version": open //./pipe/docker_engine: The system cannot find the file specified.
The following steps solved this problem:
Open cmd as administrator
Launch command: "C:\Program Files\Docker\Docker\DockerCli.exe" -SwitchDaemon
some times docker might be disabled from starting on boot or login so in the windows search bar or when clicking the WinKey and starting to type Dock... like showen in the picture below, Then press Enter to start the Docker Daemon
Try running dockerd in a separate terminal and then try running this command.
To avoid doing this every time you can go to services -> find Docker -> select Startup Type as Automatic (Delayed) and reboot the machine.
Simple Solution: Just open Powershell and type dockerd which will start the daemon and you shall be able to use the docker now without errors.
On Windows, reason behind this issue is that Docker is not started. I tried couple of solution provided on multiple online portal to start it. What worked for me is:
In Docker Desktop if you are already logged in as a user, logout from there
Again login to docker desktop with docker account
When we login to docker account, it internally triggers the restart. So resulting if it's not started, it will start the docker for us.
I had this, but when I used a command shell elevated to Administrator, docker version was fine.
This error may indicate that the docker daemon is not running.: Get "http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.24/containers/json": open //./pipe/docker_engine: The system cannot find the file specified.
this error in windows 10
step 1
pls install (https://learn.microsoft.com/en-us/windows/wsl/install-manual#step-4---download-the-linux-kernel-update-package) Download the latest package:
this link WSL2 Linux kernel update package for x64 machines
then restart then automatically running
In my case,
I download the this github repo.MaxySpark
Closed all the application related to docker.
1.Click on docker.reg file in the downloaded repo.
2.Click on yes->yes->ok to merge.
3.Again open the Docker Toolbox and run docker run hello-world
Open cmd as administrator
Launch command: C:\Program Files\Docker\Docker\DockerCli.exe -SwitchDaemon
It simply means that your docker application is not running or you have not logged in to docker application, or docker desktop service is not running .
1: Just open Docker desktop application, login with docker credentials.
2: if already logged in and still getting this error, go to windows + r ==> and type 'services.msc', and restart the docker desktop service.
All done.
It can be kernel problem:
You need to update WSL2 Linux kernel update package for x64 machines
Follow this tutorial:
https://linuxhint.com/resolve-docker-daemon-not-running/
and before execute "docker run hello-world" command, dont forget restart docker
https://learn.microsoft.com/en-us/windows/wsl/install-manual

Not able to start docker Desktop in Windows

I am not able to start the Docker container in Microsoft Windows 10 profession. As I found the cause of this error is due to the docker engine is failing to start.
After installing docker I am able to run only the docker version command.
-> docker --version
As I found the error which is showing docker daemon is not running in windows while running any other docker commands on CMD.
I also enabled (checked) the Hyper-V option in "Turn Windows features on or off" in the Control panel -> Programs -> Turn Windows features on or off.
The error is related to the daemon part:
In the default daemon configuration on Windows, the docker client must be run elevated to connect.
We can switch the Docker daemon as an elevated user in order to run the docker daemon in the Windows professional:
Run below command with Windows Powershell as administrator:
Run the PowerShell command: -
& 'C:\Program Files\Docker\Docker\DockerCli.exe' -SwitchDaemon
OR
You can run the below command on CMD as administrator:
Run the CMD command: -
"C:\Program Files\Docker\Docker\DockerCli.exe" -SwitchDaemon
My Docker Desktop failed to start after I forced it to exit while updating (it stuck during the update that's why I had to do it). No solution on the Internet helped me until I ran into this Powershell command:
wsl -l -v
It listed the following:
* Ubuntu-18.04 Stopped 2
docker-desktop Uninstalling 2
docker-desktop-data Stopped 2
It kept saying "Uninstalling" even after rebooting the whole system.
What I did was:
wsl -t docker-desktop
It terminated docker-desktop and made the problem gone.
delete %appdata%\Docker\settings.json and let Docker to create a new one
You should check WSL:
Execute "wsl -l -v" at the command prompt.
If the result is like this:
Then execute "wsl --shutdown" on the command line.
Then execute "wsl -l -v", you will see:
Then start Docker Desktop.
This solved my problem.
Make sure to download the Linux Kernel Update Package and then try restarting Docker Desktop.
Download from here
Just share my experience how I solved the problem with "docker failed to start" or similar problem. I found some mess with my Win10 Home edition, despite the fact that all checkes regarding Hyper-v, wsl and others passed I got failed to start docker engine. So, I tried to install one of the old version (4.4.4), not the newest one. An voila it installed wsl2 and started without any problems!
Hope this could help someone who's tried all solutions (for example, deletion of the %appdata%\docker folders) :)
I was getting the same exact issue and a solution was provided from thread The attempted operation is not supported for the type of object referenced." error after Windows Update fixed my problem. I had tried everything before this solution. To keep it simple just follow the below steps -
Copy below snippet
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\WinSock2\Parameters\AppId_Catalog\0408F7A3]
"AppFullPath"="C:\Windows\System32\wsl.exe"
"PermittedLspCategories"=dword:80000000
Save it as a file wsl.reg
Execute the file to update the wsl registry
restart docker desktop
these steps are basically done to do some changes in the registry of wsl distribution that is installed standalone or by docker.
Using PowerShell gave me a right direction. All restarts and re-install with deletion didn't work.
wsl -l -v showed list of three processes but wsl -t docker-desktop responded with "There is no distribution with the supplied name." only. wsl --shutdown either didn't work.
Solution is next door wsl --unregister docker-desktop . After this all went fine.
I ran the following command which resolved the issue for me.
wsl --unregister docker-desktop
Please make sure your OS type requires WSL or Hyper-V to run docker as per this official link 👉 https://docs.docker.com/desktop/install/windows-install/
For my case, I am using Windows 11 Home OS, and it requires WSL (Windows Subsystem for Linux) to run docker. So that I installed WSL on my system.
Follow this link to install WSL 👉 https://learn.microsoft.com/en-us/windows/wsl/install-manual#step-4---download-the-linux-kernel-update-package
After that restart your system, then open docker (It may take up to 10 secs to start)
Hope it may solve your issue✌️

Why am I getting a "Cannot connect to the Docker daemon" error in WSL2?

Here is my setup:
Windows 10 PRO - build 19041.153 - insider program - slow ring
Ubuntu 18.04LTS subsystem in WSL2 mode
Docker for desktop 2.2.0.4 - enabled WSL2 integration with my Ubuntu subsystem
I am currently forced to use Windows for development, so I became a
Microsoft insider member and installed ubuntu with WSL2 mode. Docker desktop supports integration for WSL2, so I tried it...
For a week it worked flawlessly. Today after a PC restart, I can't get docker running again. Ubuntu can see the injected binaries from Docker desktop, but it can't connect to windows hosted docker daemon anymore.
When I call in the WSL terminal docker info it returns
$ docker info
Client:
Debug Mode: false
Server:
ERROR: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
errors pretty printing info
or with docker-compose up
ERROR: Couldn't connect to Docker daemon at http+docker://localhost - is it running?
If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable.
What I've tried already:
expose daemon without TLS with envs like DOCKER_HOST=localhost:2375, DOCKER_HOST=tcp://localhost:2375, DOCKER_HOST=127.0.0.1:2375, DOCKER_HOST=tcp://127.0.0.1:2375 => same result
uninstall Docker desktop and install previous version
turn off windows firewall
I really, really need this to work. Thanks for any ideas. Weirdest thing is it worked yesterday and I didn't make any changes in system from then...
I know this may be outdated for the present question, but this should save us precious time, especially when Windows 20H1=2004 is going to Production this month (May 2020).
  Operating System Version: Windows 10 Education (Same as Enterprise and a superset of Pro).
  Version: 2004
  Build (Version OS): 19041.264
  Others: Windows Feature Experience Pack 120.2202.130.0.
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  Shell: WSL Terminal
First, I have installed WSL v1 previously, then executed the procedure to upgrade to WSLv2, and this error shows up: "ERROR: Cannot connect to the Docker daemon at tcp://localhost:2375. Is the docker daemon running?".
Second, to fix that error, I followed instructions stated here: Link, and it worked.
Third, after some tests I think the missing change in the upgrade, was removing the DOCKER_HOST variable from shell's start script.
SUMMARY: In my case, the procedure for a permanent fix should be the following STEPs:
1. Test if it's your case unsetting DOCKER_HOST variable (See image below).
2. If the error disappears with previous step, then time to fix changes by removing the setting of the DOCKER_HOST variable in the shell's start script (In my case was *$HOME/.bashrc*).
  Commented this out:
  #export DOCKER_HOST=tcp://localhost:2375
  #export DOCKER_BUILDKIT=1
  NOTE: Also include DOCKER_BUILDKIT.
3. Close and open the Terminal.
  Test in Step 1:
Good luck!!
If it helps anyone else that is having this issue, for me it turned out that my subsystem was suddenly (and "on its own") ticked off in docker's RESOURCES > WSL INTEGRATION settings.
On the Docker Desktop app I had to manually enable my distro integration under
Settings > Resources > WSL Integration
I had installed Docker for Windows, as recommended, to use it with WSL 2 and that does indeed start the docker daemon for you. But I don't need all the fancy features it offers so removed it and was pleased to see about 4GB freed and no extra icon in the system tray.
Now if I need to run docker commands I just begin with:
sudo dockerd &
This way I can have it running on the background on the same shell. Note that in this example I have setup sudo without password. If a password is required, I can do sudo dockerd and open another terminal tab.
Although this works as a quick temporary solution I've seen it cause network issues so I would not recommend it, and prefer using a light VM instead.
I've tried soooo many things, and the stuff that worked for me, and no one ever mentioned to try:
(from Windows Powershell)
wsl --set-default <my-distro>
then and there, I could connect to docker without changing the DOCKER_HOST var.
1.open windows docker desktop --> Setting -->General --> Disable Expose daemon on tcp://localhost:2375 without TLS
2.and then Go to Settings --> Resources --> WSL integration --> uncheck Enable integration with my default WSL distro and turn off integration with distro
3.click apply and restart
4.then go to ubuntu
try docker ps
docker ps
if it does not work, continue to run the following command
unset DOCKER_HOST to disable DOCKER_HOST
Today I just tried it successfully
good luck to you
I have found my issue was due to mis-reading instructions., fixed on my windows version 1909 and WSL 2 with the following commands on CMD:
wsl.exe -l -v
wsl.exe --set-version ${distro-name} ${wsl version}
example:
C:\Users\xxxxx>wsl.exe -l -v
NAME STATE VERSION
* Ubuntu-18.04 Running 1
docker-desktop-data Running 2
docker-desktop Running 2
C:\Users\xxxxx>wsl.exe --set-version Ubuntu-18.04 2
Conversion in progress, this may take a few minutes...
For information on key differences with WSL 2 please visit https://aka.ms/wsl2
That's it
ISSUE: Cannot connect to the Docker daemon at tcp://127.0.0.1:2375
Powershell
wsl -l -v # ALL DISPLAY "2"
Linux
unset DOCKER_HOST
/etc/init.d/docker restart
Restart Docker
windows docker restart
windows firewall off
Linux docker processes
docker ps
I had the same problem, the solution for me was to set my Ubuntu as the default wsl distribution: wsl --set-default Ubuntu
For whatever it's worth (this is an old thread). Maybe someone else is still desperately trying to solve this puzzle.
I have just stumbled over the solution in my case.
I am running the following
docker desktop version 3.3.3
wsl 2
Fedora 33
Over and over again I ran into this issue "Cannot connect to the Docker daemon at unix:///var/run/docker.sock". Reinstalled, restarted, blablabla.
My ultimate error were access rights on /var/run/docker.sock, and I am running wsl under my personal user
srw-rw---- 1 root docker 0 May 7 10:29 /var/run/docker.sock
So if I run as root (sudo docker info) or I put myself into group "docker" (sudo usermod -aG docker $USER) I'm all well. Please look here https://docs.docker.com/engine/install/linux-postinstall/
There is another very basic catch:
Ensure virtualization is enabled in the BIOS.
Please enable the Virtual Machine Platform Windows feature from the selection of additional Windows Features.
Now my motherboard is being very old, the BIOS does not support
Enabling Virtualization.
Hence no solution will work for me.
WSL Version 1 or 2 will come from Windows Update automatically.
After hours, my docker worked using following method.
Go to docker desktop --> Setting -->General --> Disable Expose daemon on tcp://localhost:2375 without TLS
Go to Settings --> Resources --> WSL integration --> uncheck Enable integration with my default WSL distro and turn off integration with distro
Restart Docker desktop
Now in WSL,
unset DOCKER_HOST
Now try,
docker ps
The accepted answer is mostly correct. However, I wanted to specify that when using WSL2 + Docker Desktop:
You must unset DOCKER_HOST which was previously needed in WSL1
Mine was defined in ~/.bashrc in both Windows and WSL.
Delete in both. Also delete in Windows env variables via Control Panel.
Check with env | grep -i docker to make sure it's gone.
You must also set the correct settings in Docker Desktop
Uncheck Export daemon on tcp://localhost:2375 without TLS
Check Use the WSL2 based engine
Resources -> WSL Integration -> Check Enable integration with my default WSL distro
Now, you can do a simple docker info to check if you're running the same server version in WSL and in Windows (Powershell).
you can consider upgrading your version to 19582.1000 , it's work for me.
See this issue.

Cannot run docker 'hello world' example

I just installed docker on a Mac (docker toolbox from here; at least I hope to have it installed correctly), but when following the tutorial and type the following command
docker run hello-world
I get the following error:
docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.
Did I do something wrong? Do I miss some installation steps? Do I miss something that is 'obvious' to the experts, but not to docker beginners like me?
I don't see anything in the instructions that says anything about a 'docker daemon'...
On the shell it says:
docker is configured to use the default machine with IP aa.bb.cc.d
The version command seems to work:
Docker version 17.07.0-ce, build 8784753
Update:
I tried to start the daemon by using the command
sudo dockerd
but all I got was
sudo: dockerd: command not found
Correction: The command works, but only in the sell that opened magically during the installation. The command does not work in any other shell. But when I have to close the shell/restart the computer - what to do then? How to 'start docker???
Maybe there is a tutorial that is complete and working and explains why I need a docker-deacon, how to start it, how to start a docker image or whatever, including the complete terminology for beginners?
Docker Toolbox runs a virtual linux machine on which the docker-daemon runs. To control the virtual machine, you use the docker-machine command. For example docker-machine start to start the machine after you reboot your computer, or docker-machine stop to shut it down.
There is also the docker-machine env command which will set the environment variables needed for docker to work. Check the bottom line of it's output, it shows you how to run the command correctly to set the environment variables. Should be exec $(docker-machine env) on Mac if I'm correct. You need to set the environment variables in each shell in which you want to use docker commands.
Docker for mac starts a linux virtual machine in the background which contains the actual docker stuff. When you start a normal terminal, the terminal is not connected to the vm to execute the docker commands.
The docker quick start terminal is the one that you need to use. This terminal will execute the commands on the VM that is running in the background.
With docker toolbox, if you don't launch your terminal from the docker menu, you'll need to configure your environment separately:
eval "$(docker-machine env default)"

How to "start over" with Docker?

I am trying to run Tomcat in a Docker container with limited success. After I tried various things, I wanted to "reset" without completely deleting everything. I did stop and remove the virtual machine from the Virtualbox console. I then tried docker-machine create and docker-machine restart. My question is, if things reach a state in which the application appears to be hanging, what is the best procedure for starting from scratch that does not involve, for example, actually rebuilding the Docker container?
EDIT: All I am now asking is, given that "docker version" returns Client information but when it reaches the Server information I get the "An error occurred trying to connect" message, is what now needs to be done? What is it not connecting to? I tried with apparent success "docker-machine restart" but got no further with "docker version" after that.
First, don't delete the boot2docker VM itself (created by docker-machine)
If you want to reset, you might have to delete the container and image (quickly rebuilt with a docker build). But you can stay in the same docker-based boot2docker VM. No need for deletion.
Retrying a docker container session simply involve killing/removing the current container, and doing a new docker run.
Then, don't forget check what is not working: does a docker ps -a shows your container running? Can you access Tomcat from the boot2docker Linux host? From your actual OS host?
Based on that diagnostic and the exact content of your Dockerfile, you will be able to debug the issue.
The main issue might come from the fact docker command are executed from outside the VM.
That works only if the commands from docker-machine env <machine-name> are set.
See docker-machine env:
For cmd.exe:
$ docker-machine.exe env --shell cmd dev
set DOCKER_TLS_VERIFY=1
set DOCKER_HOST=tcp://192.168.99.101:2376
set DOCKER_CERT_PATH=C:\Users\captain\.docker\machine\machines\dev
set DOCKER_MACHINE_NAME=dev
# Run this command to configure your shell: copy and paste the above values into your command prompt.
(replace "dev" by the name of your docker machine here, probably "default")
But it is also perfectly fine to make all docker command from within the VM. No "env" to set.
Everything is on the VM (images, Dockerfile which can be on the Windows host as well, as long as it is under C:\Users\<yourLogin>, since that folder is automatically mounted as /c/Users/<yourLogin>)

Resources