remove vm by default when using docker run

This commit is contained in:
Paris Holley 2014-08-09 12:03:35 -07:00
parent 24392306ed
commit 802d17a248
3 changed files with 10 additions and 0 deletions

View File

@ -29,6 +29,9 @@ module VagrantPlugins
# Allocate a pty if it was requested # Allocate a pty if it was requested
params[:pty] = true if env[:run_pty] params[:pty] = true if env[:run_pty]
# Remove container after execution
params[:rm] = true if env[:run_rm]
# We link to our original container # We link to our original container
# TODO # TODO
end end

View File

@ -10,6 +10,7 @@ module VagrantPlugins
options = {} options = {}
options[:detach] = false options[:detach] = false
options[:pty] = false options[:pty] = false
options[:rm] = true
opts = OptionParser.new do |o| opts = OptionParser.new do |o|
o.banner = "Usage: vagrant docker-run [command...]" o.banner = "Usage: vagrant docker-run [command...]"
@ -24,6 +25,10 @@ module VagrantPlugins
o.on("-t", "--[no-]tty", "Allocate a pty") do |t| o.on("-t", "--[no-]tty", "Allocate a pty") do |t|
options[:pty] = t options[:pty] = t
end end
o.on("-r,", "--[no-]rm", "Remove container after execution") do |r|
options[:rm] = r
end
end end
# Parse out the extra args to send to SSH, which is everything # Parse out the extra args to send to SSH, which is everything
@ -56,6 +61,7 @@ module VagrantPlugins
run_command: command, run_command: command,
run_detach: options[:detach], run_detach: options[:detach],
run_pty: options[:pty], run_pty: options[:pty],
run_rm: options[:rm]
) )
end end

View File

@ -49,6 +49,7 @@ module VagrantPlugins
run_cmd += %W(--privileged) if params[:privileged] run_cmd += %W(--privileged) if params[:privileged]
run_cmd += %W(-h #{params[:hostname]}) if params[:hostname] run_cmd += %W(-h #{params[:hostname]}) if params[:hostname]
run_cmd << "-i" << "-t" if params[:pty] run_cmd << "-i" << "-t" if params[:pty]
run_cmd << "--rm=true" if params[:rm]
run_cmd += params[:extra_args] if params[:extra_args] run_cmd += params[:extra_args] if params[:extra_args]
run_cmd += [image, cmd] run_cmd += [image, cmd]