How do I create a docker machine with a specific URL using docker-machine and VirtualBox?

后端 未结 3 1142
离开以前
离开以前 2021-02-07 12:37

I can create a Docker instance with the VirtualBox driver, but I cannot figure out how to specify the URL.

Create Command:

docker-machi         


        
3条回答
  •  轮回少年
    2021-02-07 13:07

    Pending the resolution of issue 1709, I use the following script (a Windows one, to be adapted for mac).
    (Source: imranraja85 and micheletedeschi's comment)

    dmvbf.bat:
    
    @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.eth1.pid) | docker-machine ssh %machine% sudo tee /var/lib/boot2docker/bootsync.sh >NUL
    echo ifconfig eth1 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
    
    docker-machine ssh %machine% "sudo cat /var/run/udhcpc.eth1.pid | xargs sudo kill"
    
    docker-machine ssh %machine% "sudo ifconfig eth1 192.168.%ipx%.%ipy% netmask 255.255.255.0 broadcast 192.168.%ipx%.255 up"
    

    I start the vm (docker-machine start ), and then:

    dmvbf  99 101
    

    I do that only once.

    At the next docker-machine start , the IP will be 192.168.99.101.

提交回复
热议问题