diff --git a/plugins/providers/docker/action/create.rb b/plugins/providers/docker/action/create.rb index d0d65f7e8..c25223be6 100644 --- a/plugins/providers/docker/action/create.rb +++ b/plugins/providers/docker/action/create.rb @@ -43,9 +43,12 @@ module VagrantPlugins end def create_params - container_name = "#{@env[:root_path].basename.to_s}_#{@machine.name}" - container_name.gsub!(/[^-a-z0-9_]/i, "") - container_name << "_#{Time.now.to_i}" + container_name = @provider_config.name + if !container_name + container_name = "#{@env[:root_path].basename.to_s}_#{@machine.name}" + container_name.gsub!(/[^-a-z0-9_]/i, "") + container_name << "_#{Time.now.to_i}" + end links = {} @provider_config._links.each do |link| diff --git a/plugins/providers/docker/config.rb b/plugins/providers/docker/config.rb index a97ce250a..2f1476832 100644 --- a/plugins/providers/docker/config.rb +++ b/plugins/providers/docker/config.rb @@ -19,6 +19,12 @@ module VagrantPlugins # provisioning, etc. attr_accessor :has_ssh + # The name for the container. This must be unique for all containers + # on the proxy machine if it is made. + # + # @return [String] + attr_accessor :name + # True if the docker container is meant to stay in the "running" # state (is a long running process). By default this is true. # @@ -53,6 +59,7 @@ module VagrantPlugins @env = {} @has_ssh = UNSET_VALUE @image = UNSET_VALUE + @name = UNSET_VALUE @links = [] @ports = [] @privileged = UNSET_VALUE @@ -85,6 +92,7 @@ module VagrantPlugins @env ||= {} @has_ssh = false if @has_ssh == UNSET_VALUE @image = nil if @image == UNSET_VALUE + @name = nil if @name == UNSET_VALUE @privileged = false if @privileged == UNSET_VALUE @remains_running = true if @remains_running == UNSET_VALUE @vagrant_machine = nil if @vagrant_machine == UNSET_VALUE diff --git a/test/unit/plugins/providers/docker/config_spec.rb b/test/unit/plugins/providers/docker/config_spec.rb index 9f05637d5..3c71f8144 100644 --- a/test/unit/plugins/providers/docker/config_spec.rb +++ b/test/unit/plugins/providers/docker/config_spec.rb @@ -27,6 +27,7 @@ describe VagrantPlugins::DockerProvider::Config do its(:cmd) { should eq([]) } its(:env) { should eq({}) } its(:image) { should be_nil } + its(:name) { should be_nil } its(:privileged) { should be_false } its(:vagrant_machine) { should be_nil } its(:vagrant_vagrantfile) { should be_nil }