Docker bash提示不显示颜色 [英] Docker bash prompt not display color
问题描述
我使用命令: docker运行--rm -it govim bash -l </ code>运行docker映像,但
它不能显示bash提示颜色。如果我 source〜/ .bash_profile
或再次运行 bash -l </ code>,bash提示显示颜色正常。
由于 chepner 已评论(较早的回答),。 bash_profile
来源(它是一个交互式shell),因为 bash_prompt
是由 .bash_profile
调用。
但 docker issue 9299 说明 TERM
doesn' Ť似乎立即设置,强制用户打开另一个bash:
docker exec -ti test env TERM = xterm bash -l
与 issue 8755 。
To 说明/重现问题:
docker exec -ti $ CONTAINER_NAME tty
不是tty
目前的解决方法是:
docker exec -ti`your_container_id`脚本-q -c/ bin / bash/ dev / null
/ pre>
两个都假设你先运行一个运行容器,这可能不方便。
T他 OP SolomonT 报告说
docker run
withenv
做工作:docker run -rm -it -eTERM = xterm-256colorgovim bash -l
而 Fernando Correia 添加了在评论:
为了获得颜色支持并使tmux工作,我结合了两个例子:
docker exec -it my-container env TERM = xterm脚本-q -c/ bin / bash/ dev / null
I use command:
docker run --rm -it govim bash -l
to run docker images but it cannot display bash prompt color. If Isource ~/.bash_profile
or runbash -l
again, bash prompt display color like normal.My bash_profile and bash_prompt
解决方案As chepner commented (earlier answer),
.bash_profile
is sourced (itis an interactive shell), sincebash_prompt
is called by.bash_profile
.But docker issue 9299 illustrates that
TERM
doesn't seem to be set right away, forcing the users to open another bash with:docker exec -ti test env TERM=xterm bash -l
You have similar color issues with issue 8755.
To illustrate/reproduce the problem:
docker exec -ti $CONTAINER_NAME tty not a tty
The current workaround is :
docker exec -ti `your_container_id` script -q -c "/bin/bash" /dev/null
Both are supposing you have a running container first, which might not be convenient here.
The OP SolomonT reports that
docker run
withenv
do work:docker run --rm -it -e "TERM=xterm-256color" govim bash -l
And Fernando Correia adds in the comments:
To get both color support and make tmux work, I combined both examples:
docker exec -it my-container env TERM=xterm script -q -c "/bin/bash" /dev/null
这篇关于Docker bash提示不显示颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!