Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker Bash Has No Colour

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.

like image 279
cycloidistic Avatar asked Oct 25 '16 05:10

cycloidistic


People also ask

Why are my docker-compose logs all the same color?

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.

How to turn on or off colors in the Bash shell?

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:

How to set multiple colors in bash prompt in Linux?

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.

What is the difference between no_color and color in the terminal?

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.


1 Answers

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.

like image 97
Ged Avatar answered Sep 20 '22 03:09

Ged