Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to package synced folder in 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.

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

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.

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.

My questions:

  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?
like image 988
Rias Avatar asked Feb 11 '15 14:02

Rias


People also ask

How do I sync folders with Vagrant?

Vagrant automatically syncs files to and from the guest machine. This way you can edit files locally and run them in your virtual development environment. By default, Vagrant shares your project directory (the one containing the Vagrantfile) to the /vagrant directory in your guest machine.

How do I transfer files to Vagrant box?

Using SCPSCPSecure copy protocol (SCP) is a means of securely transferring computer files between a local host and a remote host or between two remote hosts. It is based on the Secure Shell (SSH) protocol. "SCP" commonly refers to both the Secure Copy Protocol and the program itself.https://en.wikipedia.org › wiki › Secure_copy_protocolSecure copy protocol - Wikipedia. Another way to copy files and folders from host to guest in Vagrant is to use to SCP. Firstly, make sure you have scp installed on your host. If you don't have it, you can install the openssh-clients package if you're using Linux or install Cygwin if you're using Windows.


1 Answers

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) 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.

like image 153
m1keil Avatar answered Sep 22 '22 12:09

m1keil