Add docker container dir to template

This commit is contained in:
Sergei A Mamonov 2017-07-17 19:08:33 +03:00 committed by Megan Marsh
parent 43c19b49e0
commit 07f7183b64
3 changed files with 19 additions and 14 deletions

View File

@ -35,6 +35,7 @@ type Config struct {
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."))
}

View File

@ -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,
}

View File

@ -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)