如何在 vagrant box 中打包同步文件夹 [英] How to package synced folder in vagrant box

查看:35
本文介绍了如何在 vagrant box 中打包同步文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

到目前为止我想要的和实现的:我想创建一个包含配置和应用程序的自定义 vagrant box,以便在不同的客户端或服务环境中重用它.

What I want and achieved so far: I want to create a custom vagrant box including a configuration and an application to reuse it in different client or serve environments.

特别是我设法创建了基于 Ubuntu(精确/64)的 vagrant box,它安装了 node.js,并用

Specifically I managed to create vagrant box, based on Ubuntu (precise/64), that has node.js installed, and package it on my dev machine with

vagrant package my-box --output filename.box

vagrant package my-box --output filename.box

我可以将 filename.box 复制到远程服务器,然后 vagrant up 那里的框.Node.js 按预期安装在 vagrant 框内.

I am able to copy the filename.box to a remote server and vagrant up the box there. Node.js is installed within the vagrant box as expected.

问题是,我无法打包同步文件夹 vagrant 中的文件.在远程服务器上启动盒子后,同步的文件夹是空的

The problem is, that I am not able to package the files in the synced folder vagrant. After starting the box on the remote server, the synced folder is empty

因此我在本地机器上开发的应用程序不包含在框中.

Therefore the application I developed on the local machine is not included in the box.

我试图找到有关此行为的解决方案或任何信息,但除了 这个未答复的帖子我在网上找不到任何东西.

I tried to find a solution or any information about this behavior, but apart from this unanswered Post i couldn't find anything on the net.

我的问题:

  1. 如何保留同步文件夹中的文件并将它们打包在 filename.box 中以便在服务器环境中重复使用.
  2. 这甚至可能吗?我看到的行为是错误还是 Vagrant 不打算打包文件?
  3. 到目前为止,我没有对同步文件夹进行任何配置.是否可以从与常规 /vagrant 不同的同步文件夹中打包文件?
  4. 如果这根本不可能,那么部署或重用流浪环境(包括应用程序)的最佳做法是什么?
  1. How can i preserve the files in the synced folder and package them in the filename.box for reuse in the server environment.
  2. Is this even possible? Is the behavior I see a bug or is Vagrant not meant to package the files also?
  3. I didn't do any configuration for the synced folders so far. Is it possible to package files from a different synced folder than the regular /vagrant?
  4. If this is not possible at all, what are best practices for deployment or reusage of vagrant environments including applications?

推荐答案

1-3) 否.这是不可能的,也不打算按照您期望的方式工作.将 VirtualBox 的共享文件夹视为远程计算机上的已安装卷.它不是虚拟机文件系统的一部分.实际数据保存在主机上,而不是虚拟机上.

1-3) No. This is not possible and not intended to work in the way you expect it to work. Think of VirtualBox's shared folder as a mounted volume on a remote machine. It's not part of the file system of your virtual machine. The actual data is saved on the host machine, not the virtual one.

4) 如果您想将数据添加到您的盒子中,只需在打包之前将您的数据复制到虚拟机即可.无需使用共享文件夹.

4) If you want to add data into your box, just copy your data over to the vm before you pack it. No need to use shared folders.

这篇关于如何在 vagrant box 中打包同步文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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