Search code examples
dockercmdconsoletty

How does Docker seemingly "upgrade" the cmd.exe console?


I'm running a neat Go application that provides an interactive shell with colors, "special" chars, and a normal POSIXey readline experience.

When I run the app directly in cmd.exe (on Windows 10 Pro 64-bit 1903), it shows a warning about color support and is slightly degraded (please ignore the errors that might be my machine setup).

cmd> bettercap.exe

WARNING: This terminal does not support colors, view will be very limited.

enter image description here

When I run the same app in cmd.exe via Docker, I get a similar degraded experience.

$ docker run --rm bettercap/bettercap

WARNING: This terminal does not support colors, view will be very limited.

enter image description here

When I run the same app in cmd.exe via Docker, but with the interactive/tty flags, I get the full Linux shell like experience and capabilities.

cmd> docker run --rm -it bettercap/bettercap

enter image description here

What I want to understand (at any level, honestly) is how Docker can seemingly "upgrade" the console's capabilities. As far as I know cmd.exe just can't do those things? I am familiar with the articles about the recent ConPTY upgrades, but I'm not sure I grok it fully or understand how that is or is not in play here.


Solution

  • Docker did not "Upgrade" CMD, CMD allows color, it's up to the executable running in CMD to be coded to send color to the screen.

    Essentially You just told Docker to go ahead and do that.

    ie. You can write an executable in say C# that runs on the CLI (CMD), and writes any text in some arbitrary color of your choosing that CMD supports, and it will show up just fine.

    For the life of me, I have NO Idea why Microsoft purposely chose not to colorize 99% their own commands in CMD/DOS for the last 30 years.

    Although I imagine now it's something they consider a wasted effort at this point, since they did colorize Powershell and are committed to continuing that forward especially now that it supports Linux.

    Also Note:

    CMD itself allows you to change the FG and BG Color of the entire prompt at one time.

    It's also possible to write CMD Scripts which colorize portions of text BG/FG throughout them without changing the entire prompt by a kludge using "FindStr" or VBScript, and PowerShell as well