{"record":{"id":"848935f6a9f3ee63","repo":"docker/compose","slug":"no-such-service-s","errorCode":null,"errorMessage":"no such service: %s","messagePattern":"no such service: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/compose/ps.go","lineNumber":106,"sourceCode":"\tflags.BoolVar(&opts.Services, \"services\", false, \"Display services\")\n\tflags.BoolVar(&opts.Orphans, \"orphans\", true, \"Include orphaned services (not declared by project)\")\n\tflags.BoolVarP(&opts.All, \"all\", \"a\", false, \"Show all stopped containers (including those created by the run command)\")\n\tflags.BoolVar(&opts.noTrunc, \"no-trunc\", false, \"Don't truncate output\")\n\treturn psCmd\n}\n\nfunc runPs(ctx context.Context, dockerCli command.Cli, backendOptions *BackendOptions, services []string, opts psOptions) error { //nolint:gocyclo\n\tproject, name, err := opts.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\tif len(services) > 0 {\n\t\t\tfor _, service := range services {\n\t\t\t\tif !slices.Contains(names, service) {\n\t\t\t\t\treturn fmt.Errorf(\"no such service: %s\", service)\n\t\t\t\t}\n\t\t\t}\n\t\t} else if !opts.Orphans {\n\t\t\t// until user asks to list orphaned services, we only include those declared in project\n\t\t\tservices = names\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\tcontainers, err := backend.Ps(ctx, name, api.PsOptions{\n\t\tProject:  project,\n\t\tAll:      opts.All || len(opts.Status) != 0,\n\t\tServices: services,\n\t})\n\tif err != nil {","sourceCodeStart":88,"sourceCodeEnd":124,"githubUrl":"https://github.com/docker/compose/blob/ddc4b044b62e9f715212ea4143fa830fac76382f/cmd/compose/ps.go#L88-L124","documentation":"When a compose project could be loaded, `docker compose ps` validates each requested positional service name against the project's declared services and rejects any name not present in the compose file. Only when no project can be resolved does it skip this check.","triggerScenarios":"Running `docker compose ps typo-name` where the compose file defines other services; using an old service name after it was renamed in the file; querying a service defined only in an override file that isn't included.","commonSituations":"Renamed or removed services in a refactor; wrong -f file selection so the intended service isn't defined; CI scripts hardcoding service names that drift from the compose file.","solutions":["List available services with `docker compose config --services` and correct the name.","Ensure the right compose files are loaded (`-f`, `COMPOSE_FILE`, working directory) so the service is actually defined.","Derive service names in scripts from `docker compose config --services` instead of hardcoding."],"exampleFix":"# before\ndocker compose ps webapp  # service was renamed to api\n\n# after\ndocker compose config --services\ndocker compose ps api","handlingStrategy":"validation","validationCode":"# bash: verify requested services exist before ps\nmapfile -t DEFINED < <(docker compose config --services)\nfor want in \"$@\"; do\n  printf '%s\\n' \"${DEFINED[@]}\" | grep -qx \"$want\" || { echo \"no such service: $want\" >&2; exit 2; }\ndone\ndocker compose ps \"$@\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Generate service lists from `docker compose config --services` in scripts.","After renaming services, grep CI for the old names."],"tags":["cli","ps","service-name","validation"],"backgroundTag":null,"analyzedSha":"ddc4b044b62e9f715212ea4143fa830fac76382f","analyzedAt":"2026-08-15T13:31:42.319Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}