【问题标题】:How can I run the command to force docker-machine to create a vm with specific address in Windows 10 Home?如何运行命令强制 docker-machine 在 Windows 10 Home 中创建具有特定地址的 vm?
【发布时间】:2019-03-14 11:12:46
【问题描述】:

我一直在关注这个问题来强制 docker-machine 创建一个具有特定地址 Is there a way to force docker-machine to create vm with a specific ip? 的 vm,因为我需要 docker-machine 在 192.168.99.100 上工作。它似乎适用于所有人,但不适用于我,我认为为 Windows Home 解决它可能会有所帮助

我正在使用:

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

命令的第二部分不起作用:

docker-machine ssh 默认 sudo tee /var/lib/boot2docker/bootsync.sh > /dev/null

脚本也不起作用: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"

这么说

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.

谢谢

【问题讨论】:

    标签: docker docker-machine


    【解决方案1】:

    您面临的错误似乎不言自明:机器“默认”似乎不存在或没有运行。

    首先,通过在提升的 powershell 中键入以下内容来确保机器存在:

     docker-machine ls
    

    如果您看到该机器,请输入以下内容以确保它正在运行:

    docker-machine start MyMachineName
    

    否则,创建一个新的:

    docker-machine create MyMachineName
    

    它可能失败的另一个原因是在创建 docker-machine 时没有设置正确的虚拟开关。

    希望对你有帮助

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-12-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-16
      • 1970-01-01
      相关资源
      最近更新 更多