diff --git a/CHANGELOG.md b/CHANGELOG.md index 67030d3..8fedc1c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ FEATURES: - Support for naming containers from Vagrantfiles [#132](https://github.com/fgrehm/vagrant-lxc/issues/132) +IMPROVEMENTS: + + - Use a safer random name for containers [#152](https://github.com/fgrehm/vagrant-lxc/issues/152) + BUG FIXES: - Properly detect if lxc is installed on hosts that do not have `lxc-version` on their paths [#186](https://github.com/fgrehm/vagrant-lxc/issues/186) diff --git a/lib/vagrant-lxc/action/create.rb b/lib/vagrant-lxc/action/create.rb index dc519bb..1676e21 100644 --- a/lib/vagrant-lxc/action/create.rb +++ b/lib/vagrant-lxc/action/create.rb @@ -17,7 +17,9 @@ module Vagrant else container_name = "#{env[:root_path].basename}_#{env[:machine].name}" container_name.gsub!(/[^-a-z0-9_]/i, "") - container_name << "-#{Time.now.to_i}" + # milliseconds + random number suffix to allow for simultaneous + # `vagrant up` of the same box in different dirs + container_name << "_#{(Time.now.to_f * 1000.0).to_i}_#{rand(100000)}" end env[:machine].provider.driver.create(