我使用命令docker run --rm -it govim bash -l
运行Docker图像,但它不显示 colored颜色 输出.
如果我再次运行source ~/.bash_profile
或bash -l
,输出将正确地以 colored颜色 输出.
我使用命令docker run --rm -it govim bash -l
运行Docker图像,但它不显示 colored颜色 输出.
如果我再次运行source ~/.bash_profile
或bash -l
,输出将正确地以 colored颜色 输出.
OP SolomonT份报告显示docker run
份和env
份确实有效:
docker run --rm -it -e "TERM=xterm-256color" govim bash -l
Fernando Correia加in the comments:
为了获得这两种 colored颜色 的支持,并使
tmux
工作,我结合了这两个例子:
docker exec -it my-container env TERM=xterm-256color script -q -c "/bin/bash" /dev/null
正如chepner所 comments 的(前面的答案),.bash_profile
是源代码(它是一个交互式shell),因为bash_prompt
是called by .bash_profile
.
但docker issue 9299说明TERM
似乎没有立即设置,这迫使用户打开另一个bash:
docker exec -ti test env TERM=xterm-256color bash -l
你和issue 8755有相似的 colored颜色 问题.
到illustrate/reproduce the problem:
docker exec -ti $CONTAINER_NAME tty
not a tty
docker exec -ti `your_container_id` script -q -c "/bin/bash" /dev/null
两者都假设你先有一个运行的容器,这在这里可能不方便.