diff --git a/builder/docker/communicator.go b/builder/docker/communicator.go index 6fedf2769..63ef4cd5b 100644 --- a/builder/docker/communicator.go +++ b/builder/docker/communicator.go @@ -24,7 +24,7 @@ type Communicator struct { HostDir string ContainerDir string Version *version.Version - + Config *Config lock sync.Mutex } @@ -45,7 +45,11 @@ func (c *Communicator) Start(remote *packer.RemoteCmd) error { var cmd *exec.Cmd if c.canExec() { - cmd = exec.Command("docker", "exec", "-i", c.ContainerId, "/bin/sh") + if c.Config.Pty { + cmd = exec.Command("docker", "exec", "-i", "-t", c.ContainerId, "/bin/sh") + } else { + cmd = exec.Command("docker", "exec", "-i", c.ContainerId, "/bin/sh") + } } else { cmd = exec.Command("docker", "attach", c.ContainerId) } diff --git a/builder/docker/config.go b/builder/docker/config.go index af5f25fec..03b9dbfb0 100644 --- a/builder/docker/config.go +++ b/builder/docker/config.go @@ -28,7 +28,7 @@ type Config struct { LoginUsername string `mapstructure:"login_username"` LoginPassword string `mapstructure:"login_password"` LoginServer string `mapstructure:"login_server"` - + Pty bool ctx interpolate.Context } diff --git a/builder/docker/step_connect_docker.go b/builder/docker/step_connect_docker.go index 31f2ea2e4..315cfc204 100644 --- a/builder/docker/step_connect_docker.go +++ b/builder/docker/step_connect_docker.go @@ -7,6 +7,7 @@ import ( type StepConnectDocker struct{} func (s *StepConnectDocker) Run(state multistep.StateBag) multistep.StepAction { + config := state.Get("config").(*Config) containerId := state.Get("container_id").(string) driver := state.Get("driver").(Driver) tempDir := state.Get("temp_dir").(string) @@ -25,6 +26,7 @@ func (s *StepConnectDocker) Run(state multistep.StateBag) multistep.StepAction { HostDir: tempDir, ContainerDir: "/packer-files", Version: version, + Config: config, } state.Put("communicator", comm)