Packaging a base box with a custom Vagrantfile

前端 未结 2 1850
眼角桃花
眼角桃花 2021-02-07 06:19

I have a specific Vagrantfile for a lucid32 box that installs some pretty standard packages (PHP/MySQL/Apache), does some specific port forwarding and so on, I set it up, checko

相关标签:
2条回答
  • 2021-02-07 06:27

    This is actually all working as intended. Vagrant loads multiple Vagrantfiles (not just the one from vagrant init) when loading up, and the Vagrantfile packaged with a box is one of those. For more information, read about the "Vagrantfile Load Order" here: https://www.vagrantup.com/docs/vagrantfile/#load-order-and-merging

    In a nutshell: Vagrant loads multiple Vagrantfiles in a specific order, and merges their configurations. The box Vagrantfile is loaded as part of this process prior to the root Vagrantfile (the one from vagrant init).

    There is no way currently to make a skeleton Vagrantfile that is generated with vagrant init.

    The configuration you put in the packaged Vagrantfile, such as port forwards, should be loading in properly, since when merging configurations, it should just append all the port forwards.

    If this isn't happening, you should report a bug! But for the sake of a SO answer, this is how things are supposed to behave.

    0 讨论(0)
  • 2021-02-07 06:44

    This code worked for me

    vagrant package --output vagrant_example.box
    
    0 讨论(0)
提交回复
热议问题