问题
I've been following this question to force docker-machine to create a vm with specific address Is there a way to force docker-machine to create vm with a specific ip? because I need the docker-machine to work on 192.168.99.100. It seems to work for everybody, but not for me and I think it could be helpful to solve it for Windows Home
I'm using:
Windows 10 Home build
Virtual Box Versión 5.2.8 r121009 (Qt5.6.2)
$ docker version
Client:
Version: 18.03.0-ce
API version: 1.37
Go version: go1.9.4
Git commit: 0520e24302
Built: Fri Mar 23 08:31:36 2018
OS/Arch: windows/amd64
Experimental: false
Orchestrator: swarm
error during connect: Get https://192.168.99.101:2376/v1.37/version: dial tcp 192.168.99.101:2376: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
usuario@DESKTOP-GTCQCAR MINGW64 /c/Program Files/Docker Toolbox
$ echo "ifconfig eth0 192.168.99.100 netmask 255.255.255.0 broadcast 192.168.99.255 up" | docker-machine ssh default su
do tee /var/lib/boot2docker/bootsync.sh > /dev/null
tee: C:/Program: No such file or directory
tee: Files/Git/var/lib/boot2docker/bootsync.sh: No such file or directory
exit status 1
The second part of the command does not work:
docker-machine ssh default sudo tee /var/lib/boot2docker/bootsync.sh > /dev/null
The script does not work either: C:\Program Files\Docker Toolbox>dmvbf default 99 100
@echo off
setlocal enabledelayedexpansion
set machine=%1
if "%machine%" == "" (
echo dmvbf expects a machine name
exit /b 1
)
set ipx=%2
if "%ipx%" == "" (
echo dmvbf x missing ^(for 192.168.x.y^)
exit /b 2
)
set ipy=%3
if "%ipy%" == "" (
echo dmvbf y missing ^(for 192.168.x.y^)
exit /b 3
)
echo kill $(more /var/run/udhcpc.eth0.pid) | docker-machine ssh %machine% sudo tee /var/lib/boot2docker/bootsync.sh >NUL
echo ifconfig eth0 192.168.%ipx%.%ipy% netmask 255.255.255.0 broadcast 192.168.%ipx%.255 up | docker-machine ssh %machine% sudo tee -a /var/lib/boot2docker/bootsync.sh >NUL
echo route add default gw <gateway ip address here> | docker-machine ssh %machine% sudo tee /bar/lib/boot2docker/bootsync.sh >NUL
docker-machine ssh %machine% "sudo cat /var/run/udhcpc.eth0.pid | xargs sudo kill"
docker-machine ssh %machine% "sudo ifconfig eth0 192.168.%ipx%.%ipy% netmask 255.255.255.0 broadcast 192.168.%ipx%.255 up"
saying that
C:\Program Files\Docker Toolbox>dmvbf default 99 100
Error: Cannot run SSH command: Host "default" is not running
Error: Cannot run SSH command: Host "default" is not running
Not expected | at this momment.
Thanks
回答1:
The error you are facing seems self-explanatory: the machine "default" does not seem to exist or is not running.
First of all, make sure the machine exists by typing the following in an elevated powershell:
docker-machine ls
If you see the machine, make sure it is running by typing the following:
docker-machine start MyMachineName
Otherwise, create a new one:
docker-machine create MyMachineName
Another reason why it could fail is not having set the right virtual switch when creating your docker-machine.
Hope this helps
来源:https://stackoverflow.com/questions/55161047/how-can-i-run-the-command-to-force-docker-machine-to-create-a-vm-with-specific-a