moby: Interactive Shell. tty: Not a tty. Unable to use screen or tmux
When I try to run Screen when I run an Interactive Shell, I get the following:
$ docker run -i -t base:latest /bin/bash
[...]
root@804c415fca9e:/# screen
Must be connected to a terminal
root@804c415fca9e:/# tmux
root@804c415fca9e:/#
root@804c415fca9e:/# tty
not a tty
Although, if I create a user and getty tty, it works fine:
root@804c415fca9e:/# adduser test
root@804c415fca9e:/# getty tty
Last login: Mon May 27 22:15:24 UTC 2013 on tty
Welcome to Ubuntu 12.10 (GNU/Linux 3.8.0-19-generic x86_64)
* Documentation: https://help.ubuntu.com/
test@804c415fca9e:~$ tty
/dev/tty
Screen and tmux now launch perfectly.
On the host, lxc-ps --lxc returns:
docker-admin@docker-host:~$ lxc-ps --lxc
CONTAINER PID TTY TIME CMD
804c415fca9ed75a14e9e45c7e19e8712e45f9693fb8abed289960cb3d6bda32 7471 pts/1 00:00:00 bash
804c415fca9ed75a14e9e45c7e19e8712e45f9693fb8abed289960cb3d6bda32 7772 pts/1 00:00:00 login
804c415fca9ed75a14e9e45c7e19e8712e45f9693fb8abed289960cb3d6bda32 7783 pts/1 00:00:00 bash
Shouldn’t docker allocate a PTY/TTY when using the -t switch to the process within the container?
About this issue
- Original URL
- State: closed
- Created 11 years ago
- Comments: 29 (11 by maintainers)
For the record, it is possible to re-open stdin/stdout/stderr (with e.g. “exec >/dev/tty 2>/dev/tty </dev/tty”). This makes screen behave semi-OK, but tmux is still confused.
Thanks for the hints, here is what I’m using now:
Works perfect!
I found this to be helpful in understanding the
exec
redirection above: http://www.tldp.org/LDP/abs/html/io-redirection.htmlexec
: replace this shell with another one, in the same process>/dev/tty
: implicitly this is file descriptor “1”, stdout. So in this new shell, redirect stdout to /dev/tty2>/dev/tty
: same thing for stderr, file descriptor 2</dev/tty
: and if you get any input from /dev/tty, send that to stdin (the 0 is implied/default for input, 1 for output).at least that’s the way I’m reading it.