Why some Docker CLI subcommands have asterisks?

Viewed 150

In Docker Desktop, some CLI subcommands have asterisks (*), e.g.:

$ docker           

Usage:  docker [OPTIONS] COMMAND
(...)
Management Commands:
  builder     Manage builds
  buildx*     Build with BuildKit (Docker Inc., v0.5.1-docker)
  compose*    Docker Compose (Docker Inc., 2.0.0-beta.4)
(...)
  scan*       Docker Scan (Docker Inc., v0.8.0)
(...)

I understand these are plugins (namely buildx, compose and scan), but adding the asterisk makes no sense to me.

Why is an asterisk added to the command name and where is the source code that adds the asterisk?

1 Answers

Asterisk (*) is a decoration that shows these sub-commands are provided by plugins and not part of docker cli itself. It helps user to distinguish between built-in and plugin sub-commands. Same for provider and version of plugin in brackets which is only shown for plugins.

Asterisk itself is just "marker" and not part of the sub-command name (so to run buildx command will be just docker buildx ...). Plugins are standalone binaries which docker cli finds at runtime and their source code (if available) usually lives in their own repository - for e.g. buildx here.

Function in the docker-ce codebase that decorates all plugins with star is decoratedName() in components/cli/cli/cobra.go. That function is then used in usage message template which is rendered when listing all sub-commands.

NOTE: Links to codebase above are pointing to docker-ce repository (same function in Docker cli repository is here and template here).

Related