Issue
I use the command docker run --rm -it govim bash -l
to run Docker images, but it does not display color output.
If I source ~/.bash_profile
or run bash -l
again, output will then correctly be output with color.
My bash_profile and bash_prompt files.
Solution
The OP SolomonT reports that docker run
with env
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-256color script -q -c "/bin/bash" /dev/null
As chepner commented (earlier answer), .bash_profile
is sourced (itis an interactive shell), since bash_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-256color 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.
Answered By – VonC
This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0