moby: Docker tty is not a tty with docker exec
When I enter a running docker with “docker exec -ti mydockerinstance /bin/bash”
tty returns: not a tty and tmux doesn’t work.
I tried several things from https://github.com/docker/docker/issues/728:
docker exec -ti mydockerinstance sh -c "exec >/dev/tty 2>/dev/tty </dev/tty && /usr/bin/tmux -s /bin/bash"
getty tty
but nothing succeded.
About this issue
- Original URL
- State: closed
- Created 10 years ago
- Reactions: 13
- Comments: 127 (54 by maintainers)
Commits related to this issue
- Create a tmux wrapper to work around https://github.com/docker/docker/issues/8755 — committed to marvinpinto/kitchensink by marvinpinto 9 years ago
- update devbox launch script to avoid https://github.com/docker/docker/issues/8755 Signed-off-by: Evan Hazlett <ejhazlett@gmail.com> — committed to ehazlett/.dotfiles by ehazlett 9 years ago
- Update influxdb documentation with clarifications Removed the `docker exec` example since it doesn't appear to work because of docker/docker#8755. — committed to influxdata/docker-docs by jsternberg 8 years ago
- Update influxdb documentation with clarifications Removed the `docker exec` example since it doesn't appear to work because of docker/docker#8755. — committed to influxdata/docker-docs by jsternberg 8 years ago
- Update influxdb documentation with clarifications Removed the `docker exec` example since it doesn't appear to work because of docker/docker#8755. — committed to influxdata/docker-docs by jsternberg 8 years ago
- Fix for https://github.com/docker/docker/issues/8755 — committed to TheBiggerGuy/flatpack-gqrx by TheBiggerGuy 7 years ago
- Fix for https://github.com/docker/docker/issues/8755 v2 — committed to TheBiggerGuy/flatpack-gqrx by TheBiggerGuy 7 years ago
- Fix for https://github.com/docker/docker/issues/8755 v3 and not a good one :( — committed to TheBiggerGuy/flatpack-gqrx by TheBiggerGuy 7 years ago
- Return an error when the terminal reports zero columns and is refreshed When used within a call to `docker exec -it` where the original container does not have a TTY allocated to it (such as in docke... — committed to jsternberg/liner by jsternberg 7 years ago
- Return an error when the terminal reports zero columns and is refreshed When used within a call to `docker exec -it` where the original container does not have a TTY allocated to it (such as in docke... — committed to jsternberg/liner by jsternberg 7 years ago
- Do not rely on tty command which might be broken in containers `tty` might or might not work depending on whether a Docker container or a Kubernetes pod is run with `-t` / `tty: true`. Moreover, it d... — committed to esl/MongooseIM by erszcz 5 years ago
- Do not rely on tty command which might be broken in containers `tty` might or might not work depending on whether a Docker container or a Kubernetes pod is run with `-t` / `tty: true`. Moreover, it d... — committed to esl/MongooseIM by erszcz 5 years ago
I have a workaround :
Ok, it’s an ugly one, but with it you can use tmux when you use docker exec
@ninrod No, because it’s too late for the changes to be merged into 1.13 (the RCs have already been released). I would expect it will be fixed in 1.14 (when Docker starts using the newer version of runC).
Great work everyone. Thank you very much.
opencontainers/runc#1018 has been merged. This can be closed as soon as Docker vendors the latest commit of
runc
.With a container based on
debian:8.6
, to get both color support (e.g. forls
) andtmux
working I had to use:Fixed by #33007
@fernandoacorreia in docker 1.13, when you add
-t
, it will automatically setTERM=xterm
see https://github.com/docker/docker/pull/26461And there was much rejoicing.
@cpuguy83 when working in “dev mode” with my containers, I generally pass
-it
todocker run
and fire up tmux (i.e. when it seems useful to me to do so). It would be extremely useful (to me) to be able to fire up tmux in the context ofexec -it
, regardless of whether-it
had been passed torun
. At present, since the environment provided byexec
isnot a tty
– even when invoked with-it
flags (a pseudo-TTY is not actually allocated, apparently) – it’s not possible to use it in this way. At the very least, perhaps the--help
output ofexec
ought to be amended to indicate that its-it
mode has limitations relative torun -it
.In other words, if this is a bug, it seems like it should be fixed. If it can’t be fixed at present, or if it’s a foreseen and/or intended limitation of
exec
, then an indication should be provided in the output of--help
.This will be in 17.06
I spent a couple hours on this last night, mostly to get over the learning curve. I think I understand the majority of what I need to complete this. Most of the work is actually already done, and @crosbymichael has graciously offered to provide guidance as necessary. I’ll give another update later tonight.
@ninrod i cannot guarantee anything but we will try
@imamassi
script
will also work. The fix exists within runc (opencontainers/runc#1018) but because it’s quite a large change it’s not been merged yet. We’re hoping to get it merged by the end of the month (in time for OCI 1.0-rc2).This should be fixed with opencontainers/runc#1018
Sent from my iPhone
Quoting @brauner from lxc/lxc#554 “This is a known bug in glibc and @hallyn has send a fix to glibc (https://sourceware.org/ml/libc-alpha/2016-08/msg00307.html). It just needs to be applied.”
Serge’s fix is surprising and elegant.
The version is YY.MM, and we target first week of the month, so first week of June, with release candidates before that
Quick update… I was able to get a container running via
ctr
, so I think I may have gotten over that hump. I’ve been learning a lot about how the whole thing works (containerd-shim etc). I think I now have everything I need to be able to test my changes once I implement them. Will provide another update soon.Ok so a quick update; I think I can get this finished in a few days…
At this point I have my development environment up and running, such that I can iterate on the
containerd
codebase.However, I’ve become stuck; I’ll ping @crosbymichael tomorrow for help, but I can’t seem to start an OCI bundle that was created via
runc spec
withctr containers start
… and I need to be able to usectr containers exec
to test my changes.I’m using the docs here https://github.com/docker/containerd/blob/v0.2.x/docs/bundle.md to create the OCI bundle. I’m able to run the bundle using
runc start
(version v0.0.9), but as mentioned when trying to start the container usingctr
, I get the following error:Once I get this working, dropping in the changes should be as simple as consuming the https://github.com/crosbymichael/go-runc bindings that already support the new console functionality.
hi @cyphar, little lost here. So will this be fixed in docker 1.13?
The underlying issue is that we allocate a PTY outside the container’s mount namespace (so the PTY devices aren’t inside the container’s
/dev
partition), so the pseudomagical/proc/self/fd/{0,1,2}
symlinks are “broken”. This breaks the way that things likesu
check if it’s being run in a TTY –stat(ttyname(0))
or similar.Unfortunately I run coreos and running tmux on the host is not desirable, because I don’t want to modify the host image at all, just run docker images for everything. This bug impedes that.
On 18 March 2015 22:17:15 GMT+00:00, dbabits notifications@github.com wrote:
Sent from my Android device with K-9 Mail. Please excuse my brevity.