diff --git a/cli/command/node/cmd.go b/cli/command/node/cmd.go index e71b9199ad47e122391e79b1895db0e67dde56ae..6bb6c3b28ad6dfd363ca0aa030d03a47163bc94d 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 92c990a97537700a0d36be6794055dbb5c17a489..33046d2cb8736ea1c0174d6eba37aa7b75d15745 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 07f0c7bb91e9a46705c0e5fe66e980ee93c48dcc..46efb096f9593044f91a24188ebf8c80932daab9 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 79e669858c1aca9b487728f868aa382980993761..acaef4dcac18cb082c614bb1488a0fb6eaccc760 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 796fe926c3153cee21ce29283a4ea81028942323..51208b80c25041930135f2a6d1345336e0689e8a 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 632679c4b6a72019f14e0cd00cb5546e582517ee..659dbcdf7b0bc38f33b5a0e3414d340e691c20ec 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 4ef83813330dae9ed36a0b71379dcb7a3e370bea..9086c992487ccb6d471c13693ffdf126e003030c 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 570a52a72e68648f76275fb481dd4277c9c4b36f..8d589d4416ee549669cb863e9cee7b68e3dee70f 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{}