docker/compose · error
no such service: %s
Error message
no such service: %s
What it means
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.
Source
Thrown at cmd/compose/volumes.go:69
}
cmd.Flags().BoolVarP(&options.Quiet, "quiet", "q", false, "Only display volume names")
cmd.Flags().StringVar(&options.Format, "format", "table", flags.FormatHelp)
return cmd
}
func runVol(ctx context.Context, dockerCli command.Cli, backendOptions *BackendOptions, services []string, options volumesOptions) error {
project, name, err := options.projectOrName(ctx, dockerCli, services...)
if err != nil {
return err
}
if project != nil {
names := project.ServiceNames()
for _, service := range services {
if !slices.Contains(names, service) {
return fmt.Errorf("no such service: %s", service)
}
}
}
backend, err := compose.NewComposeService(dockerCli, backendOptions.Options...)
if err != nil {
return err
}
volumes, err := backend.Volumes(ctx, name, api.VolumesOptions{
Services: services,
})
if err != nil {
return err
}
if options.Quiet {
for _, v := range volumes {
_, _ = fmt.Fprintln(dockerCli.Out(), v.Name)View on GitHub (pinned to ddc4b044b6)
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.
Example fix
# before # positional args are SERVICE names, not volume names docker compose volume ls db-data # after docker compose volume ls db
Defensive patterns
Strategy: validation
Validate before calling
for svc in "$@"; do
docker compose config --services | grep -qx "$svc" || { echo "no such service: $svc" >&2; exit 2; }
done
docker compose volume ls "$@" Prevention
- Remember positional args here are SERVICE names, not volume names.
- Validate against config --services with the same profile/env context.
When it happens
Trigger: `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.
Common situations: 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.
Related errors
- --no-recreate and --renew-anon-volumes are incompatible
- cannot attach to services not included in up: %s
- --wait-timeout must be a non-negative integer
- --abort-on-container-failure cannot be combined with --abort
- --wait cannot be combined with --abort-on-container-exit, --
AI-assisted analysis of docker/compose@ddc4b044b6 (2026-08-15).
Data as JSON: /api/errors/0fd29ad2508b9b8d.
Report an issue: GitHub.