{"id":"2a866fb77b94b37c","repo":"docker/cli","slug":"max-concurrent-can-only-be-used-with-replicated-jo","errorCode":null,"errorMessage":"max-concurrent can only be used with replicated-job mode","messagePattern":"max-concurrent can only be used with replicated-job mode","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/command/service/opts.go","lineNumber":636,"sourceCode":"\t\tcapAdd:          opts.NewListOpts(nil),\n\t\tcapDrop:         opts.NewListOpts(nil),\n\t\tulimits:         *opts.NewUlimitOpt(nil),\n\t}\n}\n\nfunc (options *serviceOptions) ToServiceMode() (swarm.ServiceMode, error) {\n\tserviceMode := swarm.ServiceMode{}\n\tswitch options.mode {\n\tcase \"global\":\n\t\tif options.replicas.Value() != nil {\n\t\t\treturn serviceMode, errors.New(\"replicas can only be used with replicated or replicated-job mode\")\n\t\t}\n\n\t\tif options.maxReplicas > 0 {\n\t\t\treturn serviceMode, errors.New(\"replicas-max-per-node can only be used with replicated or replicated-job mode\")\n\t\t}\n\t\tif options.maxConcurrent.Value() != nil {\n\t\t\treturn serviceMode, errors.New(\"max-concurrent can only be used with replicated-job mode\")\n\t\t}\n\n\t\tserviceMode.Global = &swarm.GlobalService{}\n\tcase \"replicated\":\n\t\tif options.maxConcurrent.Value() != nil {\n\t\t\treturn serviceMode, errors.New(\"max-concurrent can only be used with replicated-job mode\")\n\t\t}\n\n\t\tserviceMode.Replicated = &swarm.ReplicatedService{\n\t\t\tReplicas: options.replicas.Value(),\n\t\t}\n\tcase \"replicated-job\":\n\t\tconcurrent := options.maxConcurrent.Value()\n\t\tif concurrent == nil {\n\t\t\tconcurrent = options.replicas.Value()\n\t\t}\n\t\tserviceMode.ReplicatedJob = &swarm.ReplicatedJob{\n\t\t\tMaxConcurrent:    concurrent,","sourceCodeStart":618,"sourceCodeEnd":654,"githubUrl":"https://github.com/docker/cli/blob/e9452d6e785f6e365712b9d71bd7517591773c86/cli/command/service/opts.go#L618-L654","documentation":"Raised in ToServiceMode when --max-concurrent is set (options.maxConcurrent.Value() != nil) while mode is 'global'. Max-concurrent limits how many job tasks run simultaneously and only applies to replicated-job services; a global service is a long-running per-node service with no concurrency window.","triggerScenarios":"`docker service create --mode global --max-concurrent N ...`; ToServiceMode with mode=='global' and a non-nil maxConcurrent.","commonSituations":"Confusing global services with global-job batch workloads; reusing a replicated-job command line after changing the mode; assuming max-concurrent throttles rollout like update-parallelism.","solutions":["Use --mode replicated-job if you want a batch job with limited concurrency (--max-concurrent N).","If you meant to throttle rolling updates of a service, use --update-parallelism instead.","Otherwise remove --max-concurrent from the global-mode command."],"exampleFix":"# before\ndocker service create --mode global --max-concurrent 2 my-batch\n# after\ndocker service create --mode replicated-job --replicas 10 --max-concurrent 2 my-batch","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":["docker","swarm","cli","jobs","flag-validation"],"analyzedSha":"e9452d6e785f6e365712b9d71bd7517591773c86","analyzedAt":"2026-08-01T07:09:22.474Z","schemaVersion":2}