gpt4 book ai didi

docker - 安装 Docker 后 Vagrant 挂载错误

转载 作者:IT老高 更新时间:2023-10-28 21:24:45 26 4
gpt4 key购买 nike

我在我的 Vagrant 虚拟机中遇到了一个奇怪的错误。因此,我使用 VirtualBox 创建了一个新的 ubuntu/trusty64 虚拟机(如果有人关心的话,在 OS X 上)。

一切都好……

然后我按照 instructions 安装了 Docker这基本上涉及运行

wget -qO- https://get.docker.com/ | sh

这也很好用。

然后我重新启动虚拟机,退出 ssh shell,然后运行 ​​vagrant reload 并收到此错误消息。

Failed to mount folders in Linux guest. This is usually because
the "vboxsf" file system is not available. Please verify that
the guest additions are properly installed in the guest and
can work properly. The command attempted was:

mount -t vboxsf -o uid=`id -u vagrant`,gid=`getent group vagrant | cut -d: -f3` vagrant /vagrant
mount -t vboxsf -o uid=`id -u vagrant`,gid=`id -g vagrant` vagrant /vagrant

The error output from the last command was:

stdin: is not a tty
/sbin/mount.vboxsf: mounting failed with the error: No such device

有什么想法吗?

最佳答案

我也遇到过类似的问题。看起来 Docker(以及可能的其他工具)在安装后会更新您的 Ubuntu/Trusty64 guest 中的内核版本。由于预装在 Ubuntu/Trusty64 中的 VBox GuestAdditions 是专门针对原始内核版本构建的,因此 Guest Additions 将在下一个 vagrant upvagrant reload 因为那是 Docker 安装的新内核启动的时候。此时,Vagrant 不再能够自动挂载 /vagrant 文件夹(或任何同步的文件夹)为Guest Additions 是针对不同的内核构建的。

要让它们再次工作,您必须针对 Docker 安装的新内核版本重建 GuestAdditions。

幸运的是,在 Vagrant 中有一个名为 vagrant-vbguest 的插件,它会在插件检测到需要重建时自动重建 guest 添加(例如,当 guest 中的内核发生更改时,或者您在主机中升级了 VirtualBox 版本)

所以在我的情况下,修复它的简单方法是:

  • 在主机上:$ vagrant plugin install vagrant-vbguest
  • 在客户机上:$ sudo apt-get install linux-headers-$(uname -r)
  • 在主机上:$ vagrant reload

感谢 vagrant-vbguest 插件,新的 VBox GuestAdditions 将根据您的内核的新版本自动重建(您将在上面的第二步中下载所需的头文件)。

一旦 GuestAdditions 恢复正常,同步文件夹应该会再次工作,并且 /vagrant 的映射应该会成功。

试一试。

关于docker - 安装 Docker 后 Vagrant 挂载错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31616383/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com