Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No colorized output #2231

Closed
yajo opened this issue Oct 20, 2015 · 19 comments
Closed

No colorized output #2231

yajo opened this issue Oct 20, 2015 · 19 comments

Comments

@yajo
Copy link

yajo commented Oct 20, 2015

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.

@hadim
Copy link

hadim commented Nov 26, 2015

I confirm the bug. docker run outputs the correct colorized logs if they exist.

@aanand
Copy link

aanand commented Dec 7, 2015

Can you provide a minimal failing case? I've got logs producing correctly coloured output with a small docker-compose.yml:

test:
  image: ubuntu:14.04
  command: ['sh', '-c', 'echo \\033[31mhello; echo \\033[32mworld']

screen shot 2015-12-07 at 14 58 47

@hadim
Copy link

hadim commented Dec 7, 2015

I don't remember what I did but I can't reproduce the bug anymore... I tried using forego which was the initial thing for what I needed colorized output, but I can't reproduce it anymore.

Wait for @yajo and see if it still se the bug before closing it maybe.

@yajo
Copy link
Author

yajo commented Dec 15, 2015

Weird, your test case works, but I'm using Odoo from yajo/odoo image and it does not show colors in docker-compose but does in plain docker. See:

captura de pantalla de 2015-12-15 20-31-39

docker-compose version
docker-compose version 1.5.2, build 7240ff3
docker-py version: 1.6.0
CPython version: 2.7.10
OpenSSL version: OpenSSL 1.0.1k-fips 8 Jan 2015

Is it possible that Odoo (Python) is doing anything to check the type of terminal and it gets different in docker-compose and docker?

@aanand
Copy link

aanand commented Dec 16, 2015

Yes, very possible. Try adding tty: true to the service config.

@yajo
Copy link
Author

yajo commented Dec 17, 2015

Amazing, it works, thanks!

@yajo yajo closed this as completed Dec 17, 2015
amon-ra pushed a commit to oondeo/docker-odoo that referenced this issue Apr 9, 2016
@Elindorath
Copy link

I don't think adding tty: true is a suitable solution since #3106 ...

@inquire
Copy link

inquire commented Aug 17, 2016

The tty:true doesn't work anymore :(

@wiktor-obrebski
Copy link

wiktor-obrebski commented Sep 11, 2016

confirm. this problem is back. @shin- maybe you can open this issue back?

@ikasty
Copy link

ikasty commented Sep 13, 2016

You can use 'cat' solution.

@wiktor-obrebski
Copy link

this is a diffrent problem, but I realized that my output color problem can be result of my app specific setup.

@mindscratch
Copy link

The tty: true works for me with docker-compose 1.9.0

@pmgouveia
Copy link

pmgouveia commented Jun 16, 2017

when I activated this... my docker-compose does not terminate anymore.. stays hanging...
#3106

@Cyral
Copy link

Cyral commented Oct 11, 2017

If you are using Node, a lot of packages use a coloring library like chalk which checks for certain things such as the --color flag or if it is a terminal to enable color support.

So just add --color when you start your app, in my case webpack didn't have color output:

"scripts": {
  "start": "./node_modules/.bin/webpack-dev-server --color",
},

@j0hnm4r5
Copy link

Adding both

tty: true

and

environment: 
    - TERM=xterm-256color`

dit it for me.

@IAMtheIAM
Copy link

IAMtheIAM commented Jun 28, 2019

Interesting, tty:truedid not work for docker-compose run service when reattaching with docker attach service_generated_name, but it does work for docker-compose up to retain color when reconnecting via docker-compose logs.

How do we get color when "attaching" to an existing docker container started by run and connected to output by docker attach?

@danvdumitriu
Copy link

A simple workaround which consists in starting docker-compose in the background, writing the output to a logfile and then tailing the logfile.

docker-compose up --build | tee /tmp/docker.log > /dev/null &
tail -f /tmp/docker.log | while IFS= read -r line; do printf '%b\n' "$line"; done

@cerinoligutom
Copy link

Adding tty: true worked for me.

Windows 10 Pro 64 bit

image

@bertho-zero
Copy link

This works for me without tty: true:

    environment:
      DEBUG_COLORS: "true"
      TERM: xterm-256color
      COLORTERM: truecolor

ewen-lbh added a commit to schoolsyst/api-next that referenced this issue Jul 26, 2020
andrewnessinjim added a commit to andrewnessinjim/story-build that referenced this issue Nov 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests