Creating, Starting, Stopping, Packaging and Publishing a Vagrant Box

I use Vagrant for local development in order to build any development environment. For example, when I need a Kubernetes multi node cluster, I can demonstrate with Vagrant quickly(https://kenanhancer.com/2019/09/08/kubernetes-multi-node-cluster-with-one-updated-vagrant-file/). After I complete my exercise about any technology, I also publish to Vagrant Cloud so that it can be used later without wasting time. But, I am not using only Vagrant, there are different technologies and there are different CLI for them. So, if I don’t use one technology sometime, I can forget some important commands. That’s why, this post is important for me to remember Vagrant CLI 🙂

To read more information about Vagrant CLI https://www.vagrantup.com/docs/cli/ follow official link.

You can reach GitHub repository from https://github.com/kenanhancer/vagrant-docker-box.git

Discovering Vagrant Boxes

We can find Vagrant boxes from this link https://app.vagrantup.com/boxes/search . Vagrant Cloud UI looks like in the following screenshot.

Vagrant Cloud (Login, Logout)

vagrant cloud auth login --check
vagrant cloud auth logout
vagrant cloud auth login

Creating a new Vagrant file

vagrant init hashicorp/precise64

Starting Vagrant machine

vagrant up

Shut down Vagrant machine

vagrant halt

Connecting with SSH

vagrant ssh

Learning Status of Vagrant machine

vagrant status

Learning Ports of Vagrant machine

vagrant port

Destroying Vagrant machine

vagrant destroy

Creating a Vagrant Package

vagrant package --output dockermachine.box --vagrantfile Vagrantfile

Publishing a Vagrant Package

vagrant cloud publish kenanhancer/DockerMachine 0.0.4 virtualbox ./dockermachine.box -d "A really cool box to download and use" --version-description "A cool version" --release --short-description "Download me"

Leave a Reply

Your email address will not be published. Required fields are marked *