Merge pull request #2462 from georgevicbell/master
Add PTY to Docker exec
This commit is contained in:
commit
2f5f6c159b
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue