whitebear
whitebear

Reputation: 12445

Make default docker-machine manually on Hyper-V

I sometimes bumped into this error on Docker for Windows.

I have googled around and found out the reason.

As a result, it is because there is no docker-machine default.

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

My OS is Windows 10 so Hyper-V is used.

SO I tryied like this,

docker-machine create --driver hyperv default

But it shows the error like this.

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

I really often obsessed with this error.

How can I fix it??


I indicated DockerNAT with hyperv-virtual-switch option.

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

it looked progress.

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!

Finally,docker-machine works.

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

However docker ps doesn't work yet.

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.

Upvotes: 1

Views: 5724

Answers (1)

gesellix
gesellix

Reputation: 3124

You can manually create an external vswitch and then select it during docker-machine create .... See https://stackoverflow.com/a/51333650/372019 for a similar question.

The blog at https://rominirani.com/docker-machine-windows-10-hyper-v-troubleshooting-tips-367c1ea73c24 gives even more details about other possible issues with docker-machine.

Upvotes: 1

Related Questions