Vagrant box sharing

For web development environment, we usually have a live environment where we call it production and some staging environments where we call them development or staging or something like that.

New features usually are introduced at the development environment where we share our works to team and get feedbacks. But in some cases, we’re in need of sharing our on-progress works to colleagues or customers and the code relying on our machine, which is often called local environment

There’re 2 ways to share your works (on vagrant box) with your colleagues and clients.

In same network

Using ‘public network’: DHCP or Static IP

Example of DHCP

Vagrant.configure("2") do |config|
    config.vm.network "public_network", type: "dhcp"
end

Then reload your virtual machine, and check the assigned ipaddress (by ipconfig command or any alternative commands)

Example of Static IP

Vagrant.configure("2") do |config|
    config.vm.network "public_network", ip: "192.168.0.99"
end

In either case, you share the ipaddress to your co-worker
It’d better to ask your co-worker to edit /etc/hosts for that Ip address, like this

// In /etc/hosts
192.168.0.99  dashboard-coworker01.local

Outside, using ‘vagrant share’.

Vagrant Share allows you to share your Vagrant environment with anyone in the world, enabling collaboration directly in your Vagrant environment in almost any network environment with just a single command: vagrant share.

In term of Vagrant Share, there’re also 3 types of sharing:
1. HTTP sharing
2. SSH sharing (not recommended)
3. General sharing

The most common way is HTTP sharing.
Simply put, after being configured, your local machine will be assigned a public url like:
http://dashboard-local-8088.vagrantshare.com

All you need to do is:
1. Create a Hashicorp’s Atlas’s account
2. Run vagrant up again

For example:
vagrant box sharing

Notes:

  • Remember to turn sharing feature off when you’re done, OR you exposed your machine to public!

Add a Comment

Scroll Up