Skip to content

[Proposal]: Use host TERM environment variable when starting TTY #2938

@kazkansouh

Description

@kazkansouh

Summary

This is a feature request for the cli to automatically pick up the hosts TERM environment variable and assign it to the container when starting with -t (tty) flag. I.e. in effect implicitly add -e TERM=${TERM} to the command line arguments when -t is present.

The current situation is to apply a default of value xterm in the engine, and this is clearly documented.

Justification

When running an interactive container from the command line its possible for the cli to pick up the correct TERM value and assign it to ensure any text editors, tools that use readline, ncurses, etc, work correctly out of the box - this should not affect the default defined in the engine that seems reasonable.

For me, I use tmux so often find small issues with key bindings due to the default of xterm.

$ echo ${TERM}
screen-256color

$ docker run -t -i --rm  alpine:latest /bin/sh -c 'echo ${TERM}'
xterm

$ docker run -t -i --rm  -e TERM=${TERM} alpine:latest /bin/sh -c 'echo ${TERM}'
screen-256color

I see two possible concerns:

  1. Running older containers might not support the same as that used on the host, esp. w.r.t. the -256color.
  2. Security risk of implicitly using a host's environment variable. E.g. running an older container that is vulnerable to something like shellshock.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions