Commit e3ab74e0 authored by georgevicbell's avatar georgevicbell

Add Config struct for docker PTY

parent 39a8ba13
...@@ -24,10 +24,14 @@ type Communicator struct { ...@@ -24,10 +24,14 @@ type Communicator struct {
HostDir string HostDir string
ContainerDir string ContainerDir string
Version *version.Version Version *version.Version
config *Config
lock sync.Mutex 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 { func (c *Communicator) Start(remote *packer.RemoteCmd) error {
// Create a temporary file to store the output. Because of a bug in // Create a temporary file to store the output. Because of a bug in
// Docker, sometimes all the output doesn't properly show up. This // Docker, sometimes all the output doesn't properly show up. This
...@@ -45,7 +49,11 @@ func (c *Communicator) Start(remote *packer.RemoteCmd) error { ...@@ -45,7 +49,11 @@ func (c *Communicator) Start(remote *packer.RemoteCmd) error {
var cmd *exec.Cmd var cmd *exec.Cmd
if c.canExec() { if c.canExec() {
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") cmd = exec.Command("docker", "exec", "-i", c.ContainerId, "/bin/sh")
}
} else { } else {
cmd = exec.Command("docker", "attach", c.ContainerId) cmd = exec.Command("docker", "attach", c.ContainerId)
} }
......
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