From a6f300f3e9888560c515eb4a475c281dfae88922 Mon Sep 17 00:00:00 2001 From: Nathan Date: Tue, 28 Apr 2015 15:35:39 -0500 Subject: [PATCH] Implement download method Use the same method as upload, in a different order --- plugins/providers/docker/communicator.rb | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/plugins/providers/docker/communicator.rb b/plugins/providers/docker/communicator.rb index fb6c9fe9e..20b0df912 100644 --- a/plugins/providers/docker/communicator.rb +++ b/plugins/providers/docker/communicator.rb @@ -31,7 +31,17 @@ module VagrantPlugins end def download(from, to) - raise "NOT IMPLEMENTED YET" + # Same process as upload, but in reverse + + # First, we use `cat` to copy that file from the Docker container. + temp = "/tmp/docker_d#{Time.now.to_i}_#{rand(100000)}" + @host_vm.communicate.execute("#{container_ssh_command} 'cat #{from}' >#{temp}") + + # Then, we download this from the host VM. + @host_vm.communicate.download(temp, to) + + # Remove the temporary file + @host_vm.communicate.execute("rm -f #{temp}", error_check: false) end def execute(command, **opts, &block)