Docker logs not showing colors (express + nodejs image)

A petty, yet interesting question (for me):

I’m trying to create docker image from a small server( nodejs + express) I wrote. My server code is:

  • Mysql socket is missing in my homestead docker container
  • Docker seccomp not working on Kali
  • Can I automate a Docker image build for a public repo I'm not a member of?
  • How to add module to Wildfly using CLI
  • Chaning tcp_keepalive_* inside a docker container
  • Chain automated builds in the same Docker Hub repository
  • var express = require('express');
    var Inflector = require('inflected');
    var colors = require('colors');
    var app = express();
    app.get('/hello/:name', function(req, res, next){
        var name = Inflector.titleize(;
        console.log("Saying hello to " + name.yellow);
        res.send('Hello ' + name);
    var port = 9090;
    app.listen(port, function(){
        console.log(('App is running on port ' + port).inverse);

    I’m creating my image with this Dockerfile:

    FROM centos:centos6
    RUN     rpm -Uvh
    RUN     yum install -y npm
    COPY . /src
    RUN cd /src; npm install
    EXPOSE 9090
    CMD ["node", "/src/index.js"]

    Building and running the image with the common commands:

    docker build -t username:centos-nodejs
    docker run -p 9090:9090 username:centos-nodejs

    I was expecting the logs to show up with colors in the command line as they do without docker (e.g. node index.js).

    What is the cause and can I fix this?

  • docker build of Dockerfile fails
  • Deploy ASP.NET core to Azure Container Service (Swarm mode)
  • 502 Bad Gateway on Docker, NPM, PHPFPM and Symfony
  • Docker & PM2: String based CMD with environment variables
  • Install PHP 5.5.30 via DockerFile instead of PHP 5.5.9
  • gcloud docker push reliability
  • 2 Solutions collect form web for “Docker logs not showing colors (express + nodejs image)”

    You need to run your container with “-it” options:

    docker run -it -p 9090:9090 username:centos-nodejs

    Not quite the answer to this specific problem, but if you’re using the debug library and have the same issue there is a non-documented environment variable that enables the colors even when in a non TTY:

    So adding DEBUG_COLORS=true to your environment variables fixes it for the debug library colors.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.