在 vagrant up 时将/etc/hosts 条目添加到主机 [英] Adding /etc/hosts entry to host machine on vagrant up

查看:33
本文介绍了在 vagrant up 时将/etc/hosts 条目添加到主机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

vagrant up 过程中是否可以修改主机上的文件?例如,在主机的 /etc/hosts 文件中添加一个条目以避免必须手动执行此操作?

解决方案

解决方案是使用 vagrant-hostsupdater

vagrant 插件安装 vagrant-hostsupdater

<块引用>

此插件会在主机系统上的/etc/hosts 文件中添加一个条目.

在 up 和 reload 命令上,它会尝试添加信息,如果不是已经存在于您的主机文件中.如果需要添加,您将被要求输入管理员密码,因为它使用 sudo 来编辑文件.

在暂停、暂停和销毁时,这些条目将再次被删除.

Is it possible for one to modify files on the host machine during the vagrant up process? For example, adding an entry to the host machine's /etc/hosts file to avoid having to do this manually?

解决方案

The solution is to use vagrant-hostsupdater

vagrant plugin install vagrant-hostsupdater

This plugin adds an entry to your /etc/hosts file on the host system.

On up and reload commands, it tries to add the information, if its not already existant in your hosts file. If it needs to be added, you will be asked for an administrator password, since it uses sudo to edit the file.

On halt, suspend and destroy, those entries will be removed again.

这篇关于在 vagrant up 时将/etc/hosts 条目添加到主机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆