debug-js / debug

A tiny JavaScript debugging utility modelled after Node.js core's debugging technique. Works in Node.js and web browsers
MIT License
11.11k stars 930 forks source link

No colors with docker-compose up. #498

Closed Kostanos closed 7 years ago

Kostanos commented 7 years ago

Hi, when I run docker image with sh or bash colors works perfectly. But when I run docker-compose up with tty: true, I see always m character on each log line, and no color, I also found that if there is some space before debug colors are working well. For example nodejs nodemon tool is showing some debug with space and without space (see screenshot).

Probably it is something more docker-compose related, but I wonder why nodemon logs some time comes with color and sometimes with m character??

Also ms at the end of the line is with colors.

fn_ws_api       |   nodemon:watch watching dir: /root/app/lib/models/ModelBase.js +0ms
fn_ws_api       |   nodemon watch is complete +0ms
fn_ws_api       | mws:info:db Connecting.. +0ms
fn_ws_api       | mws:info:index Server is listening on port - 9002 +0ms

image

thebigredgeek commented 7 years ago

As an aside, why are you running as (or under) root?

Kostanos commented 7 years ago

Do you think this may affect?

thebigredgeek commented 7 years ago

No haha. Just curious. Most people I know try to avoid root. Usually you can expose 8080 or something inside the container and then bind to some other port on the host. Usually you use HAProxy or NGinx or ELB to forward from 80 down to some other non-protected host port on your actual hardware, which is in turn mapped to another port internally within the container :P

thebigredgeek commented 7 years ago

I think for Compose it might just be the way it handles stdout/stderr. Remember, compose is piping the stream from container-specific stdout/stderr into it's own stdout/stderr. I could be wrong, but I think that might be why. @TooTallNate thoughts?

Kostanos commented 7 years ago

this image is inside private VPC subnet, with only one simple microservice app, no need other users etc... the outside proxy (nginx) is forwarding traffic to it.

Regarding compose, you are right, it is piping stream, what I don't understand why in some moments it process color well in some not..

Qix- commented 7 years ago

Most likely because it's nodemon running your program and not using Pseudo-terminals, and in fact not docker-compose's fault. That would explain why nodemon has proper debug output and the child process doesn't.

Just a guess.

Kostanos commented 7 years ago

nodemon works perfectly actually. When I run from inside container manually, it shows everything.

The issue is definitely in docker-compose + debug. docker-compose even eats some characters on simple console.log(...) after debug(...) which never happens if I don't use debug.

image

You may notice:

So I assume there is some incompatibility with docker-compose and debug;

TooTallNate commented 7 years ago

If I were to guess, nodemon is getting tripped up on the 256 color ANSI escape codes /cc @Qix-

Kostanos commented 7 years ago

@TooTallNate I tried to run app without nodemon and the issue persists.

Thank you.

TooTallNate commented 7 years ago

Ok so can you share some repro code?

Kostanos commented 7 years ago

Sure, just simple npm app with only two lines: https://gist.github.com/Kostanos/5e86e5e3f0f13fa76b65e18f6192bec7

My output of this one is:

image

as you me see "m" was added before: test This is my test for colors +0ms string

TooTallNate commented 7 years ago

I get the expected output actually:

screen shot 2017-09-18 at 12 10 39 am

What version of docker and/or docker-compose are you using? What OS? etc.

Here's mine:

$ docker --version
Docker version 17.06.2-ce, build cec0b72

$ docker-compose --version
docker-compose version 1.14.0, build c7bdf9e
Kostanos commented 7 years ago
$ docker --version
Docker version 17.05.0-ce, build 89658be

$ docker-compose --version
docker-compose version 1.9.0, build 2585387

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 16.04.3 LTS
Release:    16.04
Codename:   xenial

Will update docker-compose now, let see if it will be resolved.

Kostanos commented 7 years ago

With newer docker-compose version it works perfect:

docker-compose version 1.15.0, build e12f3b9

so it was the docker-compose issue.

Thank you @TooTallNate for your time and help!