Reputation: 466
I packed up my Spring-boot application into docker's container. Now the application's output is no longer colored. How can I fix it?
Upvotes: 5
Views: 4402
Reputation: 31
Use container with ssh
change CONTAINER_NAME and USER_NAME
docker start CONTAINER_NAME
docker container exec -d CONTAINER_NAME service ssh start # ssh should be installed!
#obtain ip address if it is not defined as static
docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' CONTAINER_NAME | xclip # xclip should be installed
ipaddress=`xclip -o`
#connect
ssh USER_NAME@$ipaddress -X
Upvotes: 0
Reputation: 41250
In your docker-compose.yml file there is a property you can set tty: true
that would tell your application that it is running in a TTY which would allow ANSI coloring when detected.
Upvotes: 6
Reputation: 500
If you run your container with the -it
flag you may see colored output. Ex:
docker run -it --rm springio/gs-spring-boot-docker
More info about the -it
flag: what is docker run -it flag?
Upvotes: 4
Reputation: 458
Actually what you are seeing when running your docker image is your application logs received from the docker engine (daemon server), but not directly from the spring application. In other words, in Docker, your application is running externally in a container but the docker server is coping real-time logs in JSON format to display it as a container output that's why it's not colored.
check the ccze Linux package it can solve the problem. Here is a related issue how-to-colorize-logs-for-docker-container
Upvotes: 2