Add Config struct for docker PTY
This commit is contained in:
parent
39a8ba1365
commit
e3ab74e09f
|
@ -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 {
|
||||||
|
|
||||||
var cmd *exec.Cmd
|
var cmd *exec.Cmd
|
||||||
if c.canExec() {
|
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 {
|
} else {
|
||||||
cmd = exec.Command("docker", "attach", c.ContainerId)
|
cmd = exec.Command("docker", "attach", c.ContainerId)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue