From e3ab74e09f9f5b73a5efa046b4b8498487a9cdf5 Mon Sep 17 00:00:00 2001 From: georgevicbell Date: Thu, 16 Jul 2015 21:06:03 -0400 Subject: [PATCH] Add Config struct for docker PTY --- builder/docker/communicator.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/builder/docker/communicator.go b/builder/docker/communicator.go index 6fedf2769..56ea3b1d3 100644 --- a/builder/docker/communicator.go +++ b/builder/docker/communicator.go @@ -24,10 +24,14 @@ type Communicator struct { HostDir string ContainerDir string Version *version.Version - + config *Config lock sync.Mutex } +type Config struct { + // Pty, if true, will request a pty from docker with -t + Pty bool +} func (c *Communicator) Start(remote *packer.RemoteCmd) error { // Create a temporary file to store the output. Because of a bug in // Docker, sometimes all the output doesn't properly show up. This @@ -45,7 +49,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) }