When I run
docker run -i -t python /bin/bash
the resulting terminal has no color.
I've looked at the following links and they haven't helped:
Docker bash prompt not display color
https://groups.google.com/forum/#!topic/docker-user/Bp4BaWRw6k4
https://github.com/docker/docker/issues/9299
I'm using the Docker Quickstart Terminal from the Docker Toolbox on Windows 10. I have docker version 1.12.0, build 8eab29e.
When using docker-compose logs, it adds colors by container, but if the container's logs were colorized, they appear all in the same color. Colorized logs are very useful, so it should be respected by docker-compose. I confirm the bug. docker run outputs the correct colorized logs if they exist.
The syntax is as follows to turn on or off colors. Please note that the following bash shell aliases are defined to display color with the ls command. Use combination of alias command and grep command as follows: You can add or remove ls command alias to the ~/.bash_profile or ~/.bashrc file. Edit file using a text editor such as vi command:
The following first command will set the text color of the prompt to blue and the next command will set the color to red. Here, 34 is the blue color code and 31 is the red color code. If you want to set multiple colors in different parts of bash prompt then you have to modify the shell variable like the following command.
The terminal is capable of color and should be able to print color when instructed. NO_COLOR is a hint to the software running in the terminal to suppress addition of color, not to the terminal to prevent any color from being shown.
To fix this you need to update the ~/.bashrc
file.
Adding something like this (borrowed from the default Ubuntu ~/.bashrc
file) should do the trick:
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
alias ls='ls --color=auto'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
fi
Once you've updated the ~/.bash
file, you need to reload the file by running source ~/.bashrc
.
You may want to create your own dockerfile which does this automatically.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With