{"record":{"id":"0fd29ad2508b9b8d","repo":"docker/compose","slug":"no-such-service-s-0fd29a","errorCode":null,"errorMessage":"no such service: %s","messagePattern":"no such service: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/compose/volumes.go","lineNumber":69,"sourceCode":"\t}\n\n\tcmd.Flags().BoolVarP(&options.Quiet, \"quiet\", \"q\", false, \"Only display volume names\")\n\tcmd.Flags().StringVar(&options.Format, \"format\", \"table\", flags.FormatHelp)\n\n\treturn cmd\n}\n\nfunc runVol(ctx context.Context, dockerCli command.Cli, backendOptions *BackendOptions, services []string, options volumesOptions) error {\n\tproject, name, err := options.projectOrName(ctx, dockerCli, services...)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif project != nil {\n\t\tnames := project.ServiceNames()\n\t\tfor _, service := range services {\n\t\t\tif !slices.Contains(names, service) {\n\t\t\t\treturn fmt.Errorf(\"no such service: %s\", service)\n\t\t\t}\n\t\t}\n\t}\n\n\tbackend, err := compose.NewComposeService(dockerCli, backendOptions.Options...)\n\tif err != nil {\n\t\treturn err\n\t}\n\tvolumes, err := backend.Volumes(ctx, name, api.VolumesOptions{\n\t\tServices: services,\n\t})\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif options.Quiet {\n\t\tfor _, v := range volumes {\n\t\t\t_, _ = fmt.Fprintln(dockerCli.Out(), v.Name)","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/docker/compose/blob/ddc4b044b62e9f715212ea4143fa830fac76382f/cmd/compose/volumes.go#L51-L87","documentation":"Returned by runVol (`docker compose volume ls`/equivalent) during argument validation when one of the SERVICE names passed on the command line is not defined in the resolved project. After options.projectOrName loads the project, each requested service is checked with slices.Contains against project.ServiceNames(); a miss aborts before the backend Volumes call. This mirrors 'no such service' errors from project.GetService but happens at CLI arg level.","triggerScenarios":"`docker compose volumes <name>` where <name> is not in compose.yml (note: it validates services, not volume names); service exists only under an inactive profile; typo; service defined in an overlay file not included in COMPOSE_FILE.","commonSituations":"Users assuming the positional arg is a volume name and passing e.g. `db-data`; renamed services; running in the wrong directory so a different compose file is loaded; profile-gated services.","solutions":["Pass a valid service name; list them with `docker compose config --services`.","Enable the profile owning the service if it is profile-gated.","Verify working directory and COMPOSE_FILE so the expected project is loaded."],"exampleFix":"# before\n# positional args are SERVICE names, not volume names\ndocker compose volume ls db-data\n\n# after\ndocker compose volume ls db","handlingStrategy":"validation","validationCode":"for svc in \"$@\"; do\n  docker compose config --services | grep -qx \"$svc\" || { echo \"no such service: $svc\" >&2; exit 2; }\ndone\ndocker compose volume ls \"$@\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Remember positional args here are SERVICE names, not volume names.","Validate against config --services with the same profile/env context."],"tags":["cli","volumes","services","validation","compose"],"backgroundTag":null,"analyzedSha":"ddc4b044b62e9f715212ea4143fa830fac76382f","analyzedAt":"2026-08-15T13:31:42.319Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}