providers/docker: stream data for run
This commit is contained in:
parent
68fe0b4258
commit
f1e1617cfd
|
@ -46,13 +46,20 @@ module VagrantPlugins
|
||||||
env[:ui].detail(" Link: #{name}:#{other}")
|
env[:ui].detail(" Link: #{name}:#{other}")
|
||||||
end
|
end
|
||||||
|
|
||||||
cid = @driver.create(params)
|
|
||||||
|
|
||||||
# If this isn't just a one-off command, then save the ID
|
|
||||||
if env[:machine_action] != :run_command
|
if env[:machine_action] != :run_command
|
||||||
|
# For regular "ups" create it and get the CID
|
||||||
|
cid = @driver.create(params)
|
||||||
env[:ui].detail(" \n"+I18n.t(
|
env[:ui].detail(" \n"+I18n.t(
|
||||||
"docker_provider.created", id: cid[0...16]))
|
"docker_provider.created", id: cid[0...16]))
|
||||||
@machine.id = cid
|
@machine.id = cid
|
||||||
|
elsif params[:detach]
|
||||||
|
env[:ui].detail(" \n"+I18n.t("docker_provider.running_detached"))
|
||||||
|
else
|
||||||
|
# For run commands, we run it and stream back the output
|
||||||
|
env[:ui].detail(" \n"+I18n.t("docker_provider.running"))
|
||||||
|
@driver.create(params) do |type, data|
|
||||||
|
env[:ui].detail(data)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@app.call(env)
|
@app.call(env)
|
||||||
|
|
|
@ -25,7 +25,7 @@ module VagrantPlugins
|
||||||
match[1]
|
match[1]
|
||||||
end
|
end
|
||||||
|
|
||||||
def create(params)
|
def create(params, &block)
|
||||||
image = params.fetch(:image)
|
image = params.fetch(:image)
|
||||||
links = params.fetch(:links)
|
links = params.fetch(:links)
|
||||||
ports = Array(params[:ports])
|
ports = Array(params[:ports])
|
||||||
|
@ -34,7 +34,7 @@ module VagrantPlugins
|
||||||
cmd = Array(params.fetch(:cmd))
|
cmd = Array(params.fetch(:cmd))
|
||||||
env = params.fetch(:env)
|
env = params.fetch(:env)
|
||||||
|
|
||||||
run_cmd = %W(docker run --name #{name} -d)
|
run_cmd = %W(docker run --name #{name})
|
||||||
run_cmd << "-d" if params[:detach]
|
run_cmd << "-d" if params[:detach]
|
||||||
run_cmd += env.map { |k,v| ['-e', "#{k}=#{v}"] }
|
run_cmd += env.map { |k,v| ['-e', "#{k}=#{v}"] }
|
||||||
run_cmd += links.map { |k, v| ['--link', "#{k}:#{v}"] }
|
run_cmd += links.map { |k, v| ['--link', "#{k}:#{v}"] }
|
||||||
|
@ -45,7 +45,7 @@ module VagrantPlugins
|
||||||
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]
|
||||||
|
|
||||||
execute(*run_cmd.flatten).chomp
|
execute(*run_cmd.flatten, &block).chomp
|
||||||
end
|
end
|
||||||
|
|
||||||
def state(cid)
|
def state(cid)
|
||||||
|
|
|
@ -45,6 +45,10 @@ en:
|
||||||
|
|
||||||
vagrant docker-run web -- rails new .
|
vagrant docker-run web -- rails new .
|
||||||
|
|
||||||
|
running: |-
|
||||||
|
Container is starting. Output will stream in below...
|
||||||
|
running_detached: |-
|
||||||
|
Container is started detached.
|
||||||
ssh_through_host_vm: |-
|
ssh_through_host_vm: |-
|
||||||
SSH will be proxied through the Docker virtual machine since we're
|
SSH will be proxied through the Docker virtual machine since we're
|
||||||
not running Docker natively. This is just a notice, and not an error.
|
not running Docker natively. This is just a notice, and not an error.
|
||||||
|
|
Loading…
Reference in New Issue