Is there a way to force docker-machine to create vm with a specific ip?

前端 未结 5 1010
生来不讨喜
生来不讨喜 2020-12-02 13:30

Is there a way to force docker-machine to create the docker vm with a specific ip (assuming that ip is available)?

5条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-02 14:08

    Yes, there is an option to create with specific ip. All you need to do is specify ip/ip-range with --virtualbox-hostonly-cidr option.

    For example:

    • when you want to assign specific ip, let say you want to assign 10.15.1.24, then appropriate config will be (the most important thing is the mask that we are using here. For specific ip you need to set subnet mask to 32) :

      docker-machine create --driver virtualbox --virtualbox-hostonly-cidr "10.15.1.24/32" dev

    • if you want to pick an ip from specific ip range, then you need to use appropriate subnet mask.

提交回复
热议问题