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

@ -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."))
}

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)