windows10环境下 vagrant+virtualBox配置centos7

vagrant版本 :vagrant_2.2.7_x86_64(安装完毕需要重启电脑)

virtualBox版本: VirtualBox-6.0.18-136238-Win

CentOS版本:  centos-7.0-x86_64.box  下载地址(使用迅雷下载到本地): http://www.vagrantbox.es/  

CMD 命令 使用:

vagrant box add {title} {url}
{title} 为虚拟机名称
{url} 本地box文件地址

vagrant init    初始化你的虚拟环境

初始化后加 虚拟机名可能初始化不成功,需要注意,并且报错:

`Vagrantfile` already exists in this directory. Remove it before running `vagrant init`.

所以直接使用: vagrant init 命令。

再启动:

vagrant up    开启你的虚拟环境

启动会报错:

Bringing machine 'default' up with 'virtualbox' provider...
==> default: Box 'base' could not be found. Attempting to find and install...
    default: Box Provider: virtualbox
    default: Box Version: >= 0
==> default: Box file was not detected as metadata. Adding it directly...
==> default: Adding box 'base' (v0) for provider: virtualbox
    default: Downloading: base
    default:
An error occurred while downloading the remote file. The error
message, if any, is reproduced below. Please fix this error and try
again.

Couldn't open file C:/Users/Fhmb/base

原因是在使用vagrant init命令初始化配置文件的时候未指定虚拟机名称:

解决办法:

1.再来一遍,重新生成Vagrantfile配置文件(使用了貌似不好用,{title} 为虚拟机额名称)

vagrant init {title} 

2.修改Vagrantfile文件中config.vm.box参数:

config.vm.box = "base" 

即 base 改为你自己命名的虚拟机名称 ;

再启动:

vagrant up    开启你的虚拟环境

启动成功并显示在virtualBox:

https://blog.csdn.net/qq_36750158/article/details/84848548

https://blog.csdn.net/lxw1844912514/article/details/100028772

感谢以上博主借鉴经验。

猜你喜欢

转载自www.cnblogs.com/hpqbh/p/12653929.html