docker/compose · error

no service selected

Error message

no service selected

What it means

Returned by `docker compose up` when running without --all (-a) and the resolved project contains zero services. After p.WithServices loads and filters the project, an empty Services map means there is nothing to start, so Compose fails fast rather than silently doing nothing. Typically the project became empty because service selection via config profiles, directory-specific compose files, or the services arg filtered everything out.

Source

Thrown at cmd/compose/up.go:141

			up.navigationMenuChanged = cmd.Flags().Changed("menu")
			if !cmd.Flags().Changed("remove-orphans") {
				create.removeOrphans = utils.StringToBool(os.Getenv(ComposeRemoveOrphans))
			}
			return validateFlags(&up, &create)
		}),
		RunE: p.WithServices(dockerCli, func(ctx context.Context, project *types.Project, services []string) error {
			create.ignoreOrphans = utils.StringToBool(project.Environment[ComposeIgnoreOrphans])
			if create.ignoreOrphans && create.removeOrphans {
				return fmt.Errorf("cannot combine %s and --remove-orphans", ComposeIgnoreOrphans)
			}
			if len(up.attach) != 0 && up.attachDependencies {
				return errors.New("cannot combine --attach and --attach-dependencies")
			}

			up.resolveNavigationMenu(dockerCli)

			if !p.All && len(project.Services) == 0 {
				return fmt.Errorf("no service selected")
			}

			return runUp(ctx, dockerCli, backendOptions, create, up, build, project, services)
		}),
		ValidArgsFunction: completeServiceNames(dockerCli, p),
	}
	flags := upCmd.Flags()
	flags.BoolVarP(&up.Detach, "detach", "d", false, "Detached mode: Run containers in the background")
	flags.BoolVar(&create.Build, "build", false, "Build images before starting containers")
	flags.BoolVar(&create.noBuild, "no-build", false, "Don't build an image, even if it's policy")
	flags.StringVar(&create.Pull, "pull", "policy", `Pull image before running ("always"|"missing"|"never")`)
	flags.BoolVar(&create.removeOrphans, "remove-orphans", false, "Remove containers for services not defined in the Compose file")
	flags.StringArrayVar(&create.scale, "scale", []string{}, "Scale SERVICE to NUM instances. Overrides the `scale` setting in the Compose file if present.")
	flags.BoolVar(&up.noColor, "no-color", false, "Produce monochrome output")
	flags.BoolVar(&up.noPrefix, "no-log-prefix", false, "Don't print prefix in logs")
	flags.BoolVar(&create.forceRecreate, "force-recreate", false, "Recreate containers even if their configuration and image haven't changed")
	flags.BoolVar(&create.noRecreate, "no-recreate", false, "If containers already exist, don't recreate them. Incompatible with --force-recreate.")
	flags.BoolVar(&up.noStart, "no-start", false, "Don't start the services after creating them")

View on GitHub (pinned to ddc4b044b6)

Solutions

  1. Activate the profiles that own your services: `COMPOSE_PROFILES=debug docker compose up` or `docker compose --profile debug up`.
  2. Verify the file actually defines services: `docker compose config --services` should list them.
  3. Check COMPOSE_FILE / working directory so the intended compose file(s) are loaded.
  4. If you genuinely want to run an empty project, pass --all (-a).

Example fix

# before
# compose.yml: services have `profiles: ["debug"]`
docker compose up

# after
docker compose --profile debug up
Defensive patterns

Strategy: validation

Validate before calling

svcs=$(docker compose config --services 2>/dev/null)
if [ -z "$svcs" ]; then echo "no services after profile filtering" >&2; exit 2; fi
docker compose up

Prevention

When it happens

Trigger: All services in compose.yml belong to profiles that are not activated (`profiles: [debug]` with no COMPOSE_PROFILES or --profile passed); running `up` in a directory whose compose file only defines top-level constructs (volumes/networks) but no services; a services arg that matches nothing; an empty compose file.

Common situations: A profile-gated service file where the user forgot to activate the profile; CI checking out only part of a multi-file setup so the merge results in zero services; COMPOSE_PROFILES left empty in a wrapper script; misnamed COMPOSE_FILE pointing at a YAML with no services key.

Related errors


AI-assisted analysis of docker/compose@ddc4b044b6 (2026-08-15). Data as JSON: /api/errors/caa3d842b6794261. Report an issue: GitHub.