Docker commands fails (in Windows)

Docker

Docker Problem Overview


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?

Docker Solutions


Solution 1 - Docker

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 - Docker

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 - Docker

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

Solution 4 - Docker

Make sure Hyper-V is up and running:

  • open elevated command prompt
  • type bcdedit /set hypervisorlaunchtype auto
  • reboot
  • run "Docker for Windows"

Solution 5 - Docker

I had to deal with the same issue on Windows.

To solve it:

  1. Create a docker machine (only if you have not got one)

     docker-machine create  default
    
  2. 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

Solution 6 - Docker

  1. Open cmd with admin rights.

  2. Execute following command >docker-machine env --shell cmd default

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

  4. Copy the highlighted line and execute on cmd

    >> @FOR /f "tokens=*" %i IN ('docker-machine env --shell cmd default') DO @%i

  5. Execute following command >docker ps

Solution 7 - Docker

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

Solution 8 - Docker

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

Solution 9 - Docker

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

Solution 10 - Docker

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.

Solution 11 - Docker

To start default host in windows I know three ways given below you can use one of them.

  1. Starting or restarting already created a default machine by the Docker:

     docker-machine start default
     docker-machine restart default
    

    Now check docker-machine env

  2. 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
    
  3. 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

Solution 12 - Docker

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,

  1. I made “Hyper-V” off (Unchecked) from “Turn Windows feature on or off”, which required the OS to be restarted.
  2. 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.

Solution 13 - Docker

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

Solution 14 - Docker

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.

Solution 15 - Docker

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

Solution 16 - Docker

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.

Solution 17 - Docker

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.

Solution 18 - Docker

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
enter image description here 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.

Solution 19 - Docker

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

Solution 20 - Docker

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.

enter image description here

Solution 21 - Docker

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

Solution 22 - Docker

In my case, all above solutions did not resolve. Instead zilurrane response helped.

    cd "C:\Program Files\Docker\Docker"
    ./DockerCli.exe -SwitchDaemon

Solution 23 - Docker

  1. Switch to Windows Containers
  2. docker info
  3. docker ps
  4. Switch back to Linux containers
  5. docker info
  6. Viola!

The windows switch likely runs the missing configurations that Linux also needs.

Solution 24 - Docker

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.

Solution 25 - Docker

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 :)

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionjimmyView Question on Stackoverflow
Solution 1 - Dockerjan.supolView Answer on Stackoverflow
Solution 2 - Dockerr590View Answer on Stackoverflow
Solution 3 - DockeraurathView Answer on Stackoverflow
Solution 4 - DockerDunkenView Answer on Stackoverflow
Solution 5 - DockerStanislavView Answer on Stackoverflow
Solution 6 - DockerShivendraView Answer on Stackoverflow
Solution 7 - DockerSunilView Answer on Stackoverflow
Solution 8 - DockerColleen LarsenView Answer on Stackoverflow
Solution 9 - DockerNBajancaView Answer on Stackoverflow
Solution 10 - DockerabmpuView Answer on Stackoverflow
Solution 11 - DockerBablu AhmedView Answer on Stackoverflow
Solution 12 - DockerDivyarajsinh JadejaView Answer on Stackoverflow
Solution 13 - DockerDylanView Answer on Stackoverflow
Solution 14 - DockerHamid ShahidView Answer on Stackoverflow
Solution 15 - DockerRoninioView Answer on Stackoverflow
Solution 16 - DockerRobGView Answer on Stackoverflow
Solution 17 - DockerLijo GeorgeView Answer on Stackoverflow
Solution 18 - DockerNditahView Answer on Stackoverflow
Solution 19 - DockerPeggyScottView Answer on Stackoverflow
Solution 20 - DockerSibeesh VenuView Answer on Stackoverflow
Solution 21 - DockerkinglaoView Answer on Stackoverflow
Solution 22 - DockerNikesh DevakiView Answer on Stackoverflow
Solution 23 - DockerrismView Answer on Stackoverflow
Solution 24 - DockerCpt KitkatView Answer on Stackoverflow
Solution 25 - DockerDialloView Answer on Stackoverflow