2017-05-19 15:01:01 +00:00
---
2017-10-20 20:26:18 +00:00
layout: "vagrant-cloud"
2017-05-19 15:01:01 +00:00
page_title: "Creating a New Vagrant Box"
sidebar_current: "vagrant-cloud-boxes-create-x"
---
# Creating a New Vagrant Box
2017-07-31 23:33:18 +00:00
This page will cover creating a new box in Vagrant Cloud and how to distribute
it to users. Boxes can be distributed without Vagrant Cloud, but
2017-05-19 16:34:03 +00:00
miss out on several [important features ](/docs/vagrant-cloud/boxes ).
2017-05-19 15:01:01 +00:00
2017-07-31 23:33:18 +00:00
There are __three ways to create and upload Vagrant Boxes to Vagrant Cloud__ . All
2017-05-19 15:01:01 +00:00
three options are outlined below.
We recommend using Packer, as is it is fully repeatable and keeps a strong
2017-07-31 23:33:18 +00:00
history of changes within Vagrant Cloud. However, for some situations, including
2017-05-19 15:01:01 +00:00
legacy workflows, the Web UI or API will work well.
2017-07-31 23:33:18 +00:00
All three options require you [sign up for Vagrant Cloud ](https://vagrantcloud.com/account/new ).
2017-05-19 15:01:01 +00:00
## Creating Boxes with Packer
Using Packer requires more up front effort, but the repeatable and
automated builds will end any manual management of boxes. Additionally,
2017-07-31 23:33:18 +00:00
all boxes will be stored and served from Vagrant Cloud, keeping a history along
2017-05-19 15:01:01 +00:00
the way.
2017-07-31 23:33:18 +00:00
## Creating Boxes via the Vagrant Cloud Web Interface
2017-05-19 15:01:01 +00:00
You'll first need to create a box file. This can be done via
the [vagrant `package` command ](http://docs.vagrantup.com/v2/boxes/base.html )
or with Packer locally.
After you've created the `.box` file, this guide can be followed.
2017-05-19 16:34:03 +00:00
1. Go to the [Create Box ](https://vagrantcloud.com/boxes/new ) page.
2017-05-19 15:01:01 +00:00
1. Name the box and give it a simple description
1. Create your first version for the box. This version
must match the format `[0-9].[0-9].[0-9]`
1. Create a provider for the box, matching the provider you need
locally in Vagrant. `virtualbox` is the most common provider.
1. Upload the `.box` file for each provider, or use a url to the `.box`
file that is publicly accessible
2017-07-31 23:33:18 +00:00
You can find all of your boxes in the [Vagrant section ](https://vagrantcloud.com/vagrant ) of Vagrant Cloud.
2017-05-19 15:01:01 +00:00
Once you've created and released a box, you can release new versions of
the box by clicking "Create New Version" under the versions sidebar on
a box page. For more information on the release lifecycle of boxes, see
2017-05-19 16:34:03 +00:00
the [help page dedicated to box lifecycle ](/docs/vagrant-cloud/boxes/lifecycle.html ).
2017-05-19 15:01:01 +00:00
## Creating Boxes with the API
2017-05-19 16:34:03 +00:00
This example uses the API to upload boxes with `curl` . To get started, you'll
need to get an [access token ](https://vagrantcloud.com/settings/tokens ).
2017-05-19 15:01:01 +00:00
Then, prepare the upload:
2017-05-19 16:34:03 +00:00
$ curl 'https://vagrantcloud.com/api/v1/box/USERNAME/BOX_NAME/version/VERSION/provider/PROVIDER_NAME/upload?access_token=ACCESS_TOKEN'
2017-05-19 15:01:01 +00:00
This should return something like this:
{
"upload_path": "https://archivist.hashicorp.com/v1/object/630e42d9-2364-2412-4121-18266770468e"
}
Then, upload your box with the following command, with the filename in this case being `foo.box` :
$ curl -X PUT --upload-file foo.box https://archivist.hashicorp.com/v1/object/630e42d9-2364-2412-4121-18266770468e
When the upload finishes, you can verify it worked by making this request and matching the `hosted_token` it returns to the previously retrieved upload token.
2017-05-19 16:34:03 +00:00
$ curl 'https://vagrantcloud.com/api/v1/box/USERNAME/BOX_NAME/version/VERSION_NUMBER/provider/PROVIDER_NAME?access_token=ACCESS_TOKEN'
2017-05-19 15:01:01 +00:00
Your box should then be available for download.