From a51f49255848a6a8b5c17f0a203b5c5b4c813c9d Mon Sep 17 00:00:00 2001 From: Matthew Hooker Date: Mon, 23 Jan 2017 13:47:22 -0800 Subject: [PATCH] communicator/docker: preserve file mode. --- builder/docker/communicator.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/builder/docker/communicator.go b/builder/docker/communicator.go index 9fadaa5c2..092782ded 100644 --- a/builder/docker/communicator.go +++ b/builder/docker/communicator.go @@ -70,11 +70,15 @@ func (c *Communicator) Upload(dst string, src io.Reader, fi *os.FileInfo) error // Copy the contents to the temporary file _, err = io.Copy(tempfile, src) - tempfile.Close() if err != nil { return err } + if fi != nil { + tempfile.Chmod((*fi).Mode()) + } + tempfile.Close() + // Copy the file into place by copying the temporary file we put // into the shared folder into the proper location in the container cmd := &packer.RemoteCmd{