title: How to enable colors in a Docker container?
body: <h1>Context</h1>
  
  <p>I have a Docker Compose with which I run several containers. My <code>docker-compose.yml</code>:</p>
  
  <pre><code>version: '2'
  
  services:
    web:
      build: ../application-web/
      ports:
       - "80:80"
      tty: true
      # Add a volume to link php code on the host and inside the container
      volumes:
       - ${application_PATH}:/usr/share/application
       - ${application_PATH}/docker_files/docker-assistant:/usr/share/assistant
      depends_on:
       - custom-php
       - custom-mysql
      links:
       - custom-php:custom-php
       - custom-mysql:custom-mysql
  
    custom-php:
      build: ../application-php/
      ports:
       - "50:50"
      tty: true
      volumes:
       - ${application_PATH}:/usr/share/application
       - ${application_PATH}/docker_files/docker-assistant:/usr/share/assistant
  
    custom-mysql:
      build: ../application-mysql/
      tty: true
      volumes:
       - ${MYSQL_DATA_PATH}:${MYSQL_DATA_PATH}
       - ${application_PATH}/sql:/usr/share/sql
       - /tmp/mysql:/var/data/mysql
      environment:
       - MYSQL_ALLOW_EMPTY_PASSWORD=yes
       - MYSQL_DATABASE=applicationdb
       - MYSQL_USER=root
       - TZ=Europe/Paris
  </code></pre>
  
  <p>We use the <code>custom-php</code> container to run unit tests in command line. Before using Docker, unit tests displayed colors in the terminal (green if everything is fine, red for each error, skipped tests in blue). </p>
  
  <h1>Problem</h1>
  
  <p>Now, return of unit tests are all in the same color. Plus when I connect myself to a running container using <code>docker exec -it compose_custom-php_1 bash</code>, it doesn't display color either.</p>
  
  <p>I tried to add the environment variable TERM=xterm like this post suggest: <a href="https://stackoverflow.com/questions/33493456/docker-bash-prompt-not-display-color">Docker bash prompt not display color</a>.
  I put it in my Dockerfile, and it works because some commands that was not working now can be executed (e.G. <code>ctrl</code> + <code>L</code>). But not the colors...</p>
  
  <h1>Question</h1>
  
  <p>What is my problem? What am I doing wrong and how can I enable colors in Docker containers?</p>