在Windows上执行docker version命令返回的结果如下:

C:\Projects> docker version
Client:
 Version:      1.13.0-dev
 API version:  1.25
 Go version:   go1.7.3
 Git commit:   d8d3314
 Built:        Tue Nov  1 03:05:34 2016
 OS/Arch:      windows/amd64
error during connect: Get http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.25/version: open //./pipe/docker_engine: The system cannot find the file
specified. In the default daemon configuration on Windows, the docker client must be run elevated to connect. This error may also indicate that the docker daemon is not running.

运行诊断将产生以下结果:

C:\Projects> wget https://github.com/Microsoft/Virtualization- 
Documentation/raw/master/windows-server-container-tools/Debug- 
ContainerHost/Debug-ContainerHost.ps1 -UseBasicParsin | iex

Checking for common problems
Describing Windows Version and Prerequisites
 [+] Is Windows 10 Anniversary Update or Windows Server 2016 608ms
 [+] Has KB3192366, KB3194496, or later installed if running Windows build 14393 141ms
 [+] Is not a build with blocking issues 29ms
Describing Docker is installed
 [-] A Docker service is installed - 'Docker' or 'com.Docker.Service'  134ms
   Expected: value to not be empty
   27:         $services | Should Not BeNullOrEmpty
   at <ScriptBlock>, <No file>: line 27
 [+] Service is running 127ms
 [+] Docker.exe is in path 2.14s
Describing User has permissions to use Docker daemon
 [+] docker.exe should not return access denied 42ms
Describing Windows container settings are correct
 [-] Do not have DisableVSmbOplock set to 1 53ms
   Expected: {0}
   But was:  {1}
   66:              $regvalue.VSmbDisableOplocks | Should Be 0
   at <ScriptBlock>, <No file>: line 66
 [+] Do not have zz values set 42ms
Describing The right container base images are installed
error during connect: Get http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.25/images/json: open //./pipe/docker_engine: The system cannot find the file specified. In the default daemon configuration on Windows, the docker client must be run elevated to connect. This error may also indicate that the docker daemon is not running.
 [-] At least one of 'microsoft/windowsservercore' or 'microsoft/nanoserver' should be installed 129ms
   ValidationMetadataException: The argument is null or empty. Provide an argument that is not null or empty, and then try the command again.
   ParameterBindingValidationException: Cannot validate argument on parameter 'Property'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again.
   at <ScriptBlock>, <No file>: line 90
Describing Container network is created
 [-] Error occurred in Describe block 1.08s
   RuntimeException: Cannot index into a null array.
   at <ScriptBlock>, <No file>: line 119
Showing output from: docker info

Showing output from: docker version
Client:
 Version:      1.13.0-dev
 API version:  1.25
 Go version:   go1.7.3
 Git commit:   d8d3314
 Built:        Tue Nov  1 03:05:34 2016
 OS/Arch:      windows/amd64

Showing output from: docker network ls

Warnings & errors from the last 24 hours
Logs saved to C:\Projects\logs_20161107-084122.csv
C:\Projects>

当前回答

尝试从提升的命令提示符运行以下命令:

SET DOCKER_CERT_PATH=C:\Users\[YourName]\.docker\machine\machines\default
SET DOCKER_HOST=tcp://[yourDockerDeamonIp]:2376
SET DOCKER_MACHINE_NAME=default
SET DOCKER_TLS_VERIFY=1
SET DOCKER_TOOLBOX_INSTALL_PATH=C:\Program Files\Docker Toolbox

您可能还会发现,即使不设置这些env变量,从docker快速启动终端运行命令也没有问题。

其他回答

您可以运行“C:\Program Files\Docker\Docker\DockerCli.exe”-SwitchDaemon并将Docker CLI指向Linux或Windows容器。这对我很管用。

The same issue arrived when I started with the docker in windows 10. I was able to run docker --version successfully but failed when I tried to run docker pull docker/whalesay. I tried many things suggested in the answers over here but my issue was resolved when I followed the below steps: 1 . Search for docker in windows and run docker desktop as administrator. 2 . Check the bottom-left docker symbol it should be green if the docker is running. 3 . If it's not running first install "wsl_update". 4 . Open the docker desktop and sign in with your docker credentials, when you are logged in you can see the server restarting and the bottom left logo turns green. 5. To check whether docker is running or not open PowerShell as administrator and run docker run hello-world.

我也遇到过同样的问题,可能是管理员的问题,所以按照下面的步骤来安装docker

windows10

.

Download docker desktop from docker hub after login to docker.Docker Desktop Installer.exe file will be downloaded. Install Docker Desktop Installer.exeusing Run as administrator -> Mark windows container during installation else it will only install linux container. It will ask for Logout after logging out and login it shows docker desktop in menu. After install, go to -> computer management -> Local users and groups -> Groups -> docker-user -> Add user in members Run docker desktop using Run as administrator Check docker whale icon in Notification tab run command >docker version Successfully using docker without any issue.

您也可以使用自诊断工具

Docker Desktop包含一个自我诊断工具,可以帮助您识别一些常见问题。运行自诊断工具前,请先找到com.docker. diagnostic .exe。通常安装在C:\Program Files\Docker\Docker\resources\ com.docker. diagnostic .exe中。

在Powershell中运行自诊断工具。

& "C:\Program Files\Docker\Docker\resources\com.docker.diagnose.exe" check

该工具运行一套检查,并在每个检查旁边显示PASS或FAIL。如果有任何失败,它会在最后突出最相关的部分。

然后执行以下命令

& 'C:\Program Files\Docker\Docker\DockerCli.exe' -SwitchDaemon

这可能是因为docker daemon选择了linux而坏了 尝试使用此命令切换到Windows或Linux 使用管理员启动powershell并运行以下命令

'C:\Program Files\Docker\Docker\DockerCli.exe' -SwitchDaemon

或以管理员身份打开cmd提示符并擦下面的命令

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