diff --git a/cli/command/container/create.go b/cli/command/container/create.go index 486d2852f9..b23f1963be 100644 --- a/cli/command/container/create.go +++ b/cli/command/container/create.go @@ -115,12 +115,6 @@ func runCreate(ctx context.Context, dockerCli command.Cli, flags *pflag.FlagSet, StatusCode: 125, } } - if err = validateAPIVersion(containerCfg, dockerCli.Client().ClientVersion()); err != nil { - return cli.StatusError{ - Status: withHelp(err, "create").Error(), - StatusCode: 125, - } - } id, err := createContainer(ctx, dockerCli, containerCfg, options) if err != nil { return err diff --git a/cli/command/container/opts.go b/cli/command/container/opts.go index 8cc44b762d..badb1b2a6b 100644 --- a/cli/command/container/opts.go +++ b/cli/command/container/opts.go @@ -13,7 +13,6 @@ import ( "strings" "time" - "github.com/docker/cli/cli/command" "github.com/docker/cli/cli/compose/loader" "github.com/docker/cli/opts" "github.com/docker/docker/api/types/container" @@ -1135,12 +1134,3 @@ func validateAttach(val string) (string, error) { } return val, errors.Errorf("valid streams are STDIN, STDOUT and STDERR") } - -func validateAPIVersion(c *containerConfig, serverAPIVersion string) error { - for _, m := range c.HostConfig.Mounts { - if err := command.ValidateMountWithAPIVersion(m, serverAPIVersion); err != nil { - return err - } - } - return nil -} diff --git a/cli/command/container/run.go b/cli/command/container/run.go index d824d8b17e..5c541a0dde 100644 --- a/cli/command/container/run.go +++ b/cli/command/container/run.go @@ -107,12 +107,6 @@ func runRun(ctx context.Context, dockerCli command.Cli, flags *pflag.FlagSet, ro StatusCode: 125, } } - if err = validateAPIVersion(containerCfg, dockerCli.CurrentVersion()); err != nil { - return cli.StatusError{ - Status: withHelp(err, "run").Error(), - StatusCode: 125, - } - } return runContainer(ctx, dockerCli, ropts, copts, containerCfg) } diff --git a/cli/command/service/create.go b/cli/command/service/create.go index 60e2b09768..fa06b32c2b 100644 --- a/cli/command/service/create.go +++ b/cli/command/service/create.go @@ -109,10 +109,6 @@ func runCreate(ctx context.Context, dockerCLI command.Cli, flags *pflag.FlagSet, return err } - if err = validateAPIVersion(service, dockerCLI.Client().ClientVersion()); err != nil { - return err - } - specifiedSecrets := opts.secrets.Value() if len(specifiedSecrets) > 0 { // parse and validate secrets diff --git a/cli/command/service/opts.go b/cli/command/service/opts.go index bd5ea0435d..ca4c5f01c5 100644 --- a/cli/command/service/opts.go +++ b/cli/command/service/opts.go @@ -11,7 +11,6 @@ import ( "strings" "time" - "github.com/docker/cli/cli/command" "github.com/docker/cli/opts" "github.com/docker/cli/opts/swarmopts" "github.com/docker/docker/api/types/container" @@ -1048,12 +1047,3 @@ const ( flagUlimitRemove = "ulimit-rm" flagOomScoreAdj = "oom-score-adj" ) - -func validateAPIVersion(c swarm.ServiceSpec, serverAPIVersion string) error { - for _, m := range c.TaskTemplate.ContainerSpec.Mounts { - if err := command.ValidateMountWithAPIVersion(m, serverAPIVersion); err != nil { - return err - } - } - return nil -} diff --git a/cli/command/utils.go b/cli/command/utils.go index 9eb17760be..de692052f6 100644 --- a/cli/command/utils.go +++ b/cli/command/utils.go @@ -16,8 +16,6 @@ import ( "github.com/docker/cli/cli/config" "github.com/docker/cli/cli/streams" "github.com/docker/docker/api/types/filters" - mounttypes "github.com/docker/docker/api/types/mount" - "github.com/docker/docker/api/types/versions" "github.com/docker/docker/errdefs" "github.com/moby/sys/sequential" "github.com/moby/term" @@ -217,17 +215,3 @@ func ValidateOutputPathFileMode(fileMode os.FileMode) error { } return nil } - -// ValidateMountWithAPIVersion validates a mount with the server API version. -func ValidateMountWithAPIVersion(m mounttypes.Mount, serverAPIVersion string) error { - if m.BindOptions != nil { - if m.BindOptions.NonRecursive && versions.LessThan(serverAPIVersion, "1.40") { - return errors.Errorf("bind-recursive=disabled requires API v1.40 or later") - } - // ReadOnlyNonRecursive can be safely ignored when API < 1.44 - if m.BindOptions.ReadOnlyForceRecursive && versions.LessThan(serverAPIVersion, "1.44") { - return errors.Errorf("bind-recursive=readonly requires API v1.44 or later") - } - } - return nil -}