docker / docker/cli

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

Open
#2,938 1 comment 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

kind/enhancement
Dominant language
Go
Stars
6.1k
Forks
2.2k
Avg merge
1d 15h
Merged PRs (30d)
43

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the Docker CLI entry point that handles the -t flag and environment options, then compare its behavior with the linked engine default in container/container.go. Define how the host TERM value should be passed only for TTY sessions, account for the compatibility and security concerns in the issue, and verify the examples produce the intended value.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, go
Domain
cli
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.