Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker container set $TERM to xterm which cause some terminal editor feature not work. #42323

Open
zw963 opened this issue Apr 26, 2021 · 4 comments
Labels
area/cli kind/enhancement Enhancements are not bugs or new features but can improve usability or performance.

Comments

@zw963
Copy link

zw963 commented Apr 26, 2021

Maybe check this link is the most easy way to undertand why this is a issue.

https://gitlab.com/craigbarnes/dte/-/issues/117#note_559774982

For a brief description, when use kitty (a terminal), it set $TERM env to xterm-kitty
automatically, even on remote VPS. it very useful, especially for dte, a editor,
which use OSC 52 escape sequence feature.

but, when use with docker, it not work, $TERM always is term.

Describe the solution you'd like
set correct $TERM when use with docker.(that is, same as current $TERM)

e.g. when run following docker command within kitty

$: docker run -it debian:jessie /bin/bash
root@54956eb7348d:/# echo $TERM                                                                                                                                
xterm  # expect this is xterm-kitty

It have to run like this to make dte editor works.

$: docker run -it -e TERM=$TERM debian:jessie /bin/bash
root@54956eb7348d:/# echo $TERM                                                                                                                                
xterm-kitty
@AkihiroSuda
Copy link
Member

If we change the CLI to propagate $TERM from the client, it may break something else, so I'm not sure the current behavior can be changed.

@AkihiroSuda AkihiroSuda added area/cli kind/enhancement Enhancements are not bugs or new features but can improve usability or performance. labels Apr 26, 2021
@zw963
Copy link
Author

zw963 commented Apr 26, 2021

Thank you, when use kitty with ssh, i found it set $TERM env automatically
on remote VPS. though i am not sure if this done by kitty or ssh, anyway, it very useful.

@x-yuri
Copy link

x-yuri commented Feb 13, 2022

@AkihiroSuda Why does docker set TERM to xterm in the first place? Is it because docker emulates xterm or... what exactly? (possibly @thaJeztah?)

@thaJeztah
Copy link
Member

thaJeztah commented Feb 13, 2022

I see the change you linked to was made as part of #163 to fix #18 looks like that may have been even before the repository was open source (so slightly before I got involved). (funny, I do see that an earlier commit on the same PR set it to the value from the host 50bee2f - my best guess here would be to keep a consistent value, and to not (by default) leak information/configuration from the client environment into the container configuration.

craigbarnes added a commit to craigbarnes/dte that referenced this issue Apr 19, 2024
This is supported by xterm, foot, ghostty, iterm2 and perhaps a few
other terminals. It serves a similar purpose to querying `terminfo(5)`
capabilities from the filesystem, but with the following advantages:

* Doesn't require a terminfo(5) entry (or database) to be installed
* Doesn't require linking to libtinfo (or reimplementing parts of it)
* Works reliably over SSH
* Works reliably (in principle, at least) when spoofing `$TERM`, as
  is done automatically in some contexts (e.g. Docker)

See also:

* https://invisible-island.net/xterm/ctlseqs/ctlseqs.html
* https://codeberg.org/dnkl/foot/src/commit/a1ac37e771edf9fe907ee09dbec0e90d447679e1/doc/foot-ctlseqs.7.scd#L756-L757
* moby/moby#42323
* https://docs.docker.com/engine/reference/run/#environment-variables
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/cli kind/enhancement Enhancements are not bugs or new features but can improve usability or performance.
Projects
None yet
Development

No branches or pull requests

4 participants