Commit 2f5f6c15 authored by Chris Bednarski's avatar Chris Bednarski

Merge pull request #2462 from georgevicbell/master

Add PTY to Docker exec
parents 39a8ba13 bf0c326c
......@@ -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)
}
......
......@@ -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
}
......
......@@ -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)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment