providers/docker: can set custom container name
This commit is contained in:
parent
58ddc66b9c
commit
61388186e9
|
@ -43,9 +43,12 @@ module VagrantPlugins
|
|||
end
|
||||
|
||||
def create_params
|
||||
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|
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 }
|
||||
|
|
Loading…
Reference in New Issue