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

时间:2018-08-19 21:36:22

标签: docker hyper-v docker-for-windows

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

我在Google周围搜索并找到了原因。

结果是因为没有docker-machine默认值。

$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/"

我真的经常迷恋这个错误。

我该如何解决?


我用DockerNAT选项指示了hyperv-virtual-switch

docker-machine create --driver hyperv --hyperv-virtual-switch DockerNAT default

它看起来很进步。

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-machine工作正常。

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.

1 个答案:

答案 0 :(得分:1)

您可以手动创建一个外部vswitch,然后在docker-machine create ...期间选择它。有关类似问题,请参见https://stackoverflow.com/a/51333650/372019

https://rominirani.com/docker-machine-windows-10-hyper-v-troubleshooting-tips-367c1ea73c24上的博客提供了有关do​​cker-machine其他可能问题的更多详细信息。