Merge pull request #7216 from hashicorp/fix_7208

fix docker tmp dir for mac
pull/7222/head
Megan Marsh 7 years ago committed by GitHub
commit f031ab56de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -4,10 +4,10 @@ import (
"context"
"fmt"
"os"
"path/filepath"
"github.com/hashicorp/packer/helper/multistep"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/packer/tmp"
)
// StepTempDir creates a temporary directory that we use in order to
@ -16,12 +16,33 @@ type StepTempDir struct {
tempDir string
}
// ConfigTmpDir returns the configuration tmp directory for Docker
func ConfigTmpDir() (string, error) {
if tmpdir := os.Getenv("PACKER_TMP_DIR"); tmpdir != "" {
return filepath.Abs(tmpdir)
}
configdir, err := packer.ConfigDir()
if err != nil {
return "", err
}
td := filepath.Join(configdir, "tmp")
_, err = os.Stat(td)
if os.IsNotExist(err) {
if err = os.MkdirAll(td, 0755); err != nil {
return "", err
}
} else if err != nil {
return "", err
}
return td, nil
}
func (s *StepTempDir) Run(_ context.Context, state multistep.StateBag) multistep.StepAction {
ui := state.Get("ui").(packer.Ui)
ui.Say("Creating a temporary directory for sharing data...")
tempdir, err := tmp.Dir("packer-docker")
tempdir, err := ConfigTmpDir()
if err != nil {
err := fmt.Errorf("Error making temp dir: %s", err)
state.Put("error", err)

@ -380,9 +380,8 @@ portable provisioning scripts.
## Overriding the host directory
By default, Packer creates a temporary folder under your system temporary
directory, and uses that to stage files for uploading into the container. If
you would like to change the path to this temporary folder, you can set
environment variable `TMPDIR` (Unix) / `TMP` `TEMP` `USERPROFILE` (Windows) .
By default, Packer creates a temporary folder under your home directory, and
uses that to stage files for uploading into the container. If you would like to
change the path to this temporary folder, you can set the `PACKER_TMP_DIR`.
This can be useful, for example, if you have your home directory permissions
set up to disallow access from the docker daemon.

Loading…
Cancel
Save