diff --git a/cli/command/node/cmd.go b/cli/command/node/cmd.go index e71b9199ad..6bb6c3b28a 100644 --- a/cli/command/node/cmd.go +++ b/cli/command/node/cmd.go @@ -15,6 +15,7 @@ func NewNodeCommand(dockerCli *command.DockerCli) *cobra.Command { Short: "Manage Swarm nodes", Args: cli.NoArgs, RunE: dockerCli.ShowHelp, + Tags: map[string]string{"version": "1.24"}, } cmd.AddCommand( newDemoteCommand(dockerCli), diff --git a/cli/command/plugin/cmd.go b/cli/command/plugin/cmd.go index 92c990a975..33046d2cb8 100644 --- a/cli/command/plugin/cmd.go +++ b/cli/command/plugin/cmd.go @@ -13,6 +13,7 @@ func NewPluginCommand(dockerCli *command.DockerCli) *cobra.Command { Short: "Manage plugins", Args: cli.NoArgs, RunE: dockerCli.ShowHelp, + Tags: map[string]string{"version": "1.25"}, } cmd.AddCommand( diff --git a/cli/command/plugin/upgrade.go b/cli/command/plugin/upgrade.go index 07f0c7bb91..46efb096f9 100644 --- a/cli/command/plugin/upgrade.go +++ b/cli/command/plugin/upgrade.go @@ -26,6 +26,7 @@ func newUpgradeCommand(dockerCli *command.DockerCli) *cobra.Command { } return runUpgrade(dockerCli, options) }, + Tags: map[string]string{"version": "1.26"}, } flags := cmd.Flags() diff --git a/cli/command/secret/cmd.go b/cli/command/secret/cmd.go index 79e669858c..acaef4dcac 100644 --- a/cli/command/secret/cmd.go +++ b/cli/command/secret/cmd.go @@ -14,6 +14,7 @@ func NewSecretCommand(dockerCli *command.DockerCli) *cobra.Command { Short: "Manage Docker secrets", Args: cli.NoArgs, RunE: dockerCli.ShowHelp, + Tags: map[string]string{"version": "1.25"}, } cmd.AddCommand( newSecretListCommand(dockerCli), diff --git a/cli/command/service/cmd.go b/cli/command/service/cmd.go index 796fe926c3..51208b80c2 100644 --- a/cli/command/service/cmd.go +++ b/cli/command/service/cmd.go @@ -14,6 +14,7 @@ func NewServiceCommand(dockerCli *command.DockerCli) *cobra.Command { Short: "Manage services", Args: cli.NoArgs, RunE: dockerCli.ShowHelp, + Tags: map[string]string{"version": "1.24"}, } cmd.AddCommand( newCreateCommand(dockerCli), diff --git a/cli/command/swarm/cmd.go b/cli/command/swarm/cmd.go index 632679c4b6..659dbcdf7b 100644 --- a/cli/command/swarm/cmd.go +++ b/cli/command/swarm/cmd.go @@ -14,6 +14,7 @@ func NewSwarmCommand(dockerCli *command.DockerCli) *cobra.Command { Short: "Manage Swarm", Args: cli.NoArgs, RunE: dockerCli.ShowHelp, + Tags: map[string]string{"version": "1.24"}, } cmd.AddCommand( newInitCommand(dockerCli), diff --git a/cli/command/volume/cmd.go b/cli/command/volume/cmd.go index 4ef8381333..9086c99248 100644 --- a/cli/command/volume/cmd.go +++ b/cli/command/volume/cmd.go @@ -13,6 +13,7 @@ func NewVolumeCommand(dockerCli *command.DockerCli) *cobra.Command { Short: "Manage volumes", Args: cli.NoArgs, RunE: dockerCli.ShowHelp, + Tags: map[string]string{"version": "1.21"}, } cmd.AddCommand( newCreateCommand(dockerCli), diff --git a/cmd/docker/docker.go b/cmd/docker/docker.go index 570a52a72e..8d589d4416 100644 --- a/cmd/docker/docker.go +++ b/cmd/docker/docker.go @@ -229,17 +229,14 @@ func hideUnsupportedFeatures(cmd *cobra.Command, clientVersion, osType string, h } func isSupported(cmd *cobra.Command, clientVersion, osType string, hasExperimental bool) error { - // We check recursively so that, e.g., `docker stack ls` will return the same output as `docker stack` - if !hasExperimental { - for curr := cmd; curr != nil; curr = curr.Parent() { - if _, ok := curr.Tags["experimental"]; ok { - return errors.New("only supported on a Docker daemon with experimental features enabled") - } + // Check recursively so that, e.g., `docker stack ls` returns the same output as `docker stack` + for curr := cmd; curr != nil; curr = curr.Parent() { + if cmdVersion, ok := curr.Tags["version"]; ok && versions.LessThan(clientVersion, cmdVersion) { + return fmt.Errorf("%s requires API version %s, but the Docker daemon API version is %s", cmd.CommandPath(), cmdVersion, clientVersion) + } + if _, ok := curr.Tags["experimental"]; ok && !hasExperimental { + return fmt.Errorf("%s is only supported on a Docker daemon with experimental features enabled", cmd.CommandPath()) } - } - - if cmdVersion, ok := cmd.Tags["version"]; ok && versions.LessThan(clientVersion, cmdVersion) { - return fmt.Errorf("requires API version %s, but the Docker daemon API version is %s", cmdVersion, clientVersion) } errs := []string{}