From c1f0fe3f3fdc26b7e9e391bd2977ec2a0798547b Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sat, 9 Nov 2013 00:05:44 -0800 Subject: [PATCH] builder/docker: fix upload for copy to work --- builder/docker/communicator.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/builder/docker/communicator.go b/builder/docker/communicator.go index 58ba732fb..ccb5830c0 100644 --- a/builder/docker/communicator.go +++ b/builder/docker/communicator.go @@ -8,6 +8,7 @@ import ( "log" "os" "os/exec" + "path/filepath" "syscall" "time" ) @@ -25,6 +26,11 @@ func (c *Communicator) Start(remote *packer.RemoteCmd) error { return err } + // TODO(mitchellh): We need to hijack the command to write the exit + // code to a temporary file in the shared folder so that we can read it + // out. Since we're going over a pty, we can't get the exit code another + // way. + cmd.Stdout = remote.Stdout cmd.Stderr = remote.Stderr @@ -74,7 +80,8 @@ func (c *Communicator) Upload(dst string, src io.Reader) error { // TODO(mitchellh): Copy the file into place cmd := &packer.RemoteCmd{ - Command: fmt.Sprintf("cp %s %s", tempfile.Name(), dst), + Command: fmt.Sprintf("cp %s/%s %s", c.ContainerDir, + filepath.Base(tempfile.Name()), dst), } if err := c.Start(cmd); err != nil {