1.先在镜像站找到需要镜像,本例为ubuntu/xenial64,版本号最新的为:v20190215.0.0
2.获取最新的下载地址,出现下载地址后,使用curl+c停止
$ vagrant box add ubuntu/xenial64
==> box: Loading metadata for box 'ubuntu/xenial64'
box: URL: https://vagrantcloud.com/ubuntu/xenial64
==> box: Adding box 'ubuntu/xenial64' (v20190215.0.0) for provider: virtualbox
box: Downloading: https://vagrantcloud.com/ubuntu/boxes/xenial64/versions/20190215.0.0/providers/virtualbox.box
box: Download redirected to host: cloud-images.ubuntu.com
box: Progress: 0% (Rate: 11010/s, Estimated time remaining: 12:02:22)^C==> box: Waiting for cleanup before exiting...
==> box: Box download was interrupted. Exiting.
https://vagrantcloud.com/ubuntu/boxes/xenial64/versions/20190215.0.0/providers/virtualbox.box
为下载地址,使用下载工具进行下载,并且重命名为“ubuntu_xenial64_20190215.box”
3.新建配置文件“metadata.json”,和下载的“ubuntu_xenial64_20190215.box”放在一级目录
{
"name": "ubuntu/xenial64",
"versions":
[
{
"version": "20190215.0.0",
"providers": [
{
"name": "virtualbox",
"url": "ubuntu_xenial64_20190215.box"
}
]
}
]
}
4.添加box
vagrant box add metadata.json