diff --git a/builder/docker/config.go b/builder/docker/config.go index 7ba1f4587..3f8f4d427 100644 --- a/builder/docker/config.go +++ b/builder/docker/config.go @@ -23,18 +23,19 @@ type Config struct { common.PackerConfig `mapstructure:",squash"` Comm communicator.Config `mapstructure:",squash"` - Commit bool - Discard bool - ExportPath string `mapstructure:"export_path"` - Image string - Pty bool - Pull bool - RunCommand []string `mapstructure:"run_command"` - Volumes map[string]string - Privileged bool `mapstructure:"privileged"` - Author string - Changes []string - Message string + Commit bool + Discard bool + ExportPath string `mapstructure:"export_path"` + Image string + Pty bool + Pull bool + RunCommand []string `mapstructure:"run_command"` + Volumes map[string]string + Privileged bool `mapstructure:"privileged"` + Author string + Changes []string + Message string + ContainerDir string `mapstructure:"container_dir"` // This is used to login to dockerhub to pull a private base container. For // pushing to dockerhub, see the docker post-processors @@ -112,6 +113,10 @@ func NewConfig(raws ...interface{}) (*Config, []string, error) { } } + if c.ContainerDir == "" { + c.ContainerDir = "/packer-files" + } + if c.EcrLogin && c.LoginServer == "" { errs = packer.MultiErrorAppend(errs, fmt.Errorf("ECR login requires login server to be provided.")) } diff --git a/builder/docker/step_connect_docker.go b/builder/docker/step_connect_docker.go index f84d369c2..7acde2ff0 100644 --- a/builder/docker/step_connect_docker.go +++ b/builder/docker/step_connect_docker.go @@ -24,7 +24,7 @@ func (s *StepConnectDocker) Run(state multistep.StateBag) multistep.StepAction { comm := &Communicator{ ContainerId: containerId, HostDir: tempDir, - ContainerDir: "/packer-files", + ContainerDir: config.ContainerDir, Version: version, Config: config, } diff --git a/builder/docker/step_run.go b/builder/docker/step_run.go index 92803f932..5a56d8d7d 100644 --- a/builder/docker/step_run.go +++ b/builder/docker/step_run.go @@ -26,7 +26,7 @@ func (s *StepRun) Run(state multistep.StateBag) multistep.StepAction { for host, container := range config.Volumes { runConfig.Volumes[host] = container } - runConfig.Volumes[tempDir] = "/packer-files" + runConfig.Volumes[tempDir] = config.ContainerDir ui.Say("Starting docker container...") containerId, err := driver.StartContainer(&runConfig)