在Hyper-V上手动设置默认docker机器

在Hyper-V上手动设置默认docker机器,docker,hyper-v,docker-for-windows,Docker,Hyper V,Docker For Windows,我有时在Docker forWindows上遇到这个错误 我在谷歌上搜索了一下,找到了原因 因此,这是因为没有默认的docker机器 $docker ps error during connect: Get http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.38/containers/json: open //./pipe/docker_engine: The system cannot find the file specified. In the defaul

我有时在Docker for
Windows
上遇到这个错误

我在谷歌上搜索了一下,找到了原因

因此,这是因为没有默认的docker机器

$docker ps
error during connect: Get http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.38/containers/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.
我的操作系统是Windows 10,因此使用Hyper-V

所以我试着这样

docker-machine create --driver hyperv default
但它显示了这样的错误

Error with pre-create check: "no External vswitch found. A valid vswitch must be available for this command to run. Check https://docs.docker.com/machine/drivers/hyper-v/"
我真的经常被这个错误困扰

我怎样才能修好它


我用
hyperv虚拟交换机
选项指示了
DockerNAT

docker机器创建--驱动程序hyperv--hyperv虚拟交换机DockerNAT默认值

它看起来有进步

Running pre-create checks...
(default) Image cache directory does not exist, creating it at C:\Users\whitebear\.docker\machine\cache...
(default) No default Boot2Docker ISO found locally, downloading the latest release...
(default) Latest release for github.com/boot2docker/boot2docker is v18.06.0-ce
(default) Downloading C:\Users\whitebear\.docker\machine\cache\boot2docker.iso from https://github.com/boot2docker/boot2docker/releases/download/v18.06.0-ce/boot2docker.iso...
(default) 0%....10%....20%....30%....40%....50%....60%....70%....80%....90%....100%
Creating machine...
(default) Copying C:\Users\whitebear\.docker\machine\cache\boot2docker.iso to C:\Users\whitebear\.docker\machine\machines\default\boot2docker.iso...
(default) Creating SSH key...
(default) Creating VM...
(default) Using switch "DockerNAT"
(default) Creating VHD
(default) Starting VM...
(default) Waiting for host to start...
Waiting for machine to be running, this may take a few minutes...
Detecting operating system of created instance...
Waiting for SSH to be available...
Detecting the provisioner...
Provisioning with boot2docker...
Copying certs to the local machine directory...
Copying certs to the remote machine...
Setting Docker configuration on the remote daemon...
Checking connection to Docker...
Docker is up and running!
最后,docker机器开始工作

PS C:\Windows\system32> docker-machine ls
NAME      ACTIVE   DRIVER   STATE     URL                        SWARM   DOCKER        ERRORS
default   -        hyperv   Running   tcp://192.168.1.118:2376           v18.06.0-ce
但是,
docker ps
还不能工作

PS C:\Windows\system32> docker ps
error during connect: Get http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.38/containers/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.

您可以手动创建外部vswitch,然后在
docker machine create…
期间选择它。有关类似问题,请参见


位于的博客提供了更多关于docker machine可能出现的其他问题的详细信息。

第一条错误消息似乎与docker machine无关,但更多的是关于停止的docker引擎。您是否验证了Docker for Windows已启动?是的,它可以工作。我确认windows服务的Docker已在windows服务窗格上启动并重新启动。命令
docker-v
返回
docker版本18.06.0-ce,build 0ffa825
docker-v
仅打印客户端版本。您可以使用
docker version
检查引擎的版本。关于更新的docker机器详细信息:默认情况下,客户端尝试通过npipe(在Windows上)连接到引擎。当使用docker machine创建的备用虚拟机时,您必须告诉客户端在哪里可以找到引擎。在这种情况下,发动机将以
tcp://192.168.1.118:2376
。请尝试类似于
docker-H的方法tcp://192.168.1.118:2376 ps
。。。。也就是说:您现在可能会遇到TLS证书问题。我仍然认为您不需要用docker机器创建另一个docker引擎,而且我仍然认为docker for Windows没有实际运行。这是开始研究的好文档。谢谢你,我应该了解更多。