Kubectl logs shows color codes instead of colors

Asking for help? Comment out what you need so we can get more information to help you!

Cluster information:

Kubernetes version: kubectl version says client version is 1.17.1 and server version is 1.15.5
Cloud being used: bare-metal (but happens on Azure too)
Installation method: Default windows 10 installation of docker desktop with kubernetes
Host OS: Windows 10
CNI and version: not sure…
CRI and version: not sure…

Hello, not sure if I’ve come to the right place for technical support about this issue, but when I use kubectl logs it shows color codes instead of colors. It does show colors when I do docker logs

Here’s a snapshot of my kubectl logs output: https://imgur.com/5kQUBFD

And here’s a snapshot of the docker logs output for the container in that same pod: https://imgur.com/J5ch9F1

Regards

Hi,

These color codes are normal in the output. You’ll have to search on the side of the terminal, which is not able to interpret them.

But why is kubectl changing the codes while docker logs keeps them?

It’s the same logs from the same container - it’s the very same terminal

Any ideas?

Is anyone else able to help?

It’s like feloy mentioned, the terminal is not interpreting the codes correctly. Kubectl is just relaying what came from the container.

I suspect docker logs has some additional logic to colorise the output.

What happens if you run kubectl from a PowerShell prompt? Do you get colours?

Kind regards,
Stephen

1 Like

Wow you are so right: kubectl logs in powershell spits out codes instead of colors, but if I pipe it through tail then suddenly it’s allright!

Click Here=></iframe>

I just pipe it through cat to work around this:

kubectl logs <container> | cat

click me