Pass --tty to docker run when running Qemu via a container

Otherwise escape codes (arrow keys etc) do not work.

This is done only when stdin is a tty.

For clarity spell `--tty-` and `--interactive` out in full rather than using
the short versions.

Signed-off-by: Ian Campbell <ian.campbell@docker.com>
This commit is contained in:
Ian Campbell
2017-05-18 18:49:04 +01:00
parent 88b6077f9a
commit 2df30ac26c
8 changed files with 1385 additions and 1 deletions

View File

@@ -11,6 +11,7 @@ import (
"strings"
log "github.com/Sirupsen/logrus"
"golang.org/x/crypto/ssh/terminal"
)
// QemuImg is the version of qemu container
@@ -178,7 +179,11 @@ func runQemuContainer(config QemuConfig) error {
var args []string
config, args = buildQemuCmdline(config)
dockerArgs := []string{"run", "-i", "--rm", "-v", fmt.Sprintf("%s:%s", wd, "/tmp"), "-w", "/tmp"}
dockerArgs := []string{"run", "--interactive", "--rm", "-v", fmt.Sprintf("%s:%s", wd, "/tmp"), "-w", "/tmp"}
if terminal.IsTerminal(int(os.Stdin.Fd())) {
dockerArgs = append(dockerArgs, "--tty")
}
if config.KVM {
dockerArgs = append(dockerArgs, "--device", "/dev/kvm")