DZone
DevOps Zone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
  • Refcardz
  • Trend Reports
  • Webinars
  • Zones
  • |
    • Agile
    • AI
    • Big Data
    • Cloud
    • Database
    • DevOps
    • Integration
    • IoT
    • Java
    • Microservices
    • Open Source
    • Performance
    • Security
    • Web Dev
DZone > DevOps Zone > Vagrant Box With This Name Already Exists

Vagrant Box With This Name Already Exists

Check out this quick fix to a common Vagrant naming error.

Lorna Mitchell user avatar by
Lorna Mitchell
·
Jul. 19, 16 · DevOps Zone · Tutorial
Like (1)
Save
Tweet
2.98K Views

Join the DZone community and get the full member experience.

Join For Free

Due to the unique approach of Canonical to packaging Vagrant boxes, the current Ubuntu/Xenial box has a hardcoded machine name which causes an error when you try to bring up a second VM using the same base box:

A VirtualBox machine with the name 'ubuntu-xenial-16.04-cloudimg' already exists.
Please use another name or delete the machine with the existing name, and try again.

There's a Stack Overflow question about this and a good answer (not the accepted one, the highest-voted one) which helped me a bit but it still wasn't completely clear to me how to fix my problem and I had to dig about a bit.

Image title


First, ask virtualbox about the VMs it knows about by doing vboxmanage list vms. My output looks like this:

"ubuntu-xenial-16.04-cloudimg-20160625_1467103387140_3797" {362a5d12-805e-498e-9068-8334b2185701}
"ubuntu-xenial-16.04-cloudimg" {5f366c5b-2526-4e30-bcc2-50ad67c9938d}
"ubuntu-xenial-16.04-cloudimg-20160625_1468498702339_50838" {bb41ec04-2e18-444a-a673-cd7f70f6b3c4

Keep this where you can see it, we'll need it in a moment.

Next, look for a file called (path relative to your Vagrantfile):

./vagrant/machines/default/virtualbox/id

(Note that default here is the machine name of the box, important if you have multiple or named VMs defined in your Vagrantfile).

The file will probably contain the identifier (in the curly braces above) from one of the VMs with a longer name. I found that I needed to replace this with the identifier of the one with the original, short box name—so, in this case, the file simply needs to contain 5f366c5b-2526-4e30-bcc2-50ad67c9938d. After making this change, the error no longer appears.

Tangent: Ubuntu/Xenial Vagrant Box Has No Guest Additions

If you're using this box then one of the other problems you will encounter is that it was packaged without the guest additions installed. Try the vagrant-vbguest plugin to fix that problem as well.

You're welcome :)

Stack overflow Identifier Machine Moment Dig (command) Overflow (software) VirtualBox Clear (Unix) Data Types

Published at DZone with permission of Lorna Mitchell, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Choosing Between REST and GraphQL
  • APIs Outside, Events Inside
  • How to Determine if Microservices Architecture Is Right for Your Business?
  • 6 Best Books to Learn Multithreading and Concurrency in Java

Comments

DevOps Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • MVB Program
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends:

DZone.com is powered by 

AnswerHub logo