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 { ...@@ -24,7 +24,7 @@ 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
} }
...@@ -45,7 +45,11 @@ func (c *Communicator) Start(remote *packer.RemoteCmd) error { ...@@ -45,7 +45,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)
} }
......
...@@ -28,7 +28,7 @@ type Config struct { ...@@ -28,7 +28,7 @@ type Config struct {
LoginUsername string `mapstructure:"login_username"` LoginUsername string `mapstructure:"login_username"`
LoginPassword string `mapstructure:"login_password"` LoginPassword string `mapstructure:"login_password"`
LoginServer string `mapstructure:"login_server"` LoginServer string `mapstructure:"login_server"`
Pty bool
ctx interpolate.Context ctx interpolate.Context
} }
......
...@@ -7,6 +7,7 @@ import ( ...@@ -7,6 +7,7 @@ import (
type StepConnectDocker struct{} type StepConnectDocker struct{}
func (s *StepConnectDocker) Run(state multistep.StateBag) multistep.StepAction { func (s *StepConnectDocker) Run(state multistep.StateBag) multistep.StepAction {
config := state.Get("config").(*Config)
containerId := state.Get("container_id").(string) containerId := state.Get("container_id").(string)
driver := state.Get("driver").(Driver) driver := state.Get("driver").(Driver)
tempDir := state.Get("temp_dir").(string) tempDir := state.Get("temp_dir").(string)
...@@ -25,6 +26,7 @@ func (s *StepConnectDocker) Run(state multistep.StateBag) multistep.StepAction { ...@@ -25,6 +26,7 @@ func (s *StepConnectDocker) Run(state multistep.StateBag) multistep.StepAction {
HostDir: tempDir, HostDir: tempDir,
ContainerDir: "/packer-files", ContainerDir: "/packer-files",
Version: version, Version: version,
Config: config,
} }
state.Put("communicator", comm) 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