{"record":{"id":"667975d774e7c31b","repo":"docker/compose","slug":"no-containers-for-project-q","errorCode":null,"errorMessage":"no containers for project %q","messagePattern":"no containers for project %q","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/compose/wait.go","lineNumber":35,"sourceCode":"package compose\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/moby/moby/client\"\n\t\"golang.org/x/sync/errgroup\"\n\n\t\"github.com/docker/compose/v5/pkg/api\"\n)\n\nfunc (s *composeService) Wait(ctx context.Context, projectName string, options api.WaitOptions) (int64, error) {\n\tcontainers, err := s.getContainers(ctx, projectName, oneOffInclude, false, options.Services...)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\tif len(containers) == 0 {\n\t\treturn 0, fmt.Errorf(\"no containers for project %q\", projectName)\n\t}\n\n\teg, waitCtx := errgroup.WithContext(ctx)\n\tvar statusCode int64\n\tfor _, ctr := range containers {\n\t\teg.Go(func() error {\n\t\t\tvar err error\n\t\t\tres := s.apiClient().ContainerWait(waitCtx, ctr.ID, client.ContainerWaitOptions{})\n\t\t\tselect {\n\t\t\tcase result := <-res.Result:\n\t\t\t\t_, _ = fmt.Fprintf(s.stdout(), \"container %q exited with status code %d\\n\", ctr.ID, result.StatusCode)\n\t\t\t\tstatusCode = result.StatusCode\n\t\t\tcase err = <-res.Error:\n\t\t\t}\n\t\t\treturn err\n\t\t})\n\t}\n","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/docker/compose/blob/ddc4b044b62e9f715212ea4143fa830fac76382f/pkg/compose/wait.go#L17-L53","documentation":"Wait (docker compose wait) lists the project's containers (including one-off ones) and refuses to continue when none exist. There is nothing to wait on for an exit code without at least one created container.","triggerScenarios":"Calling docker compose wait on a project that was never brought up, was fully down-removed, or whose remaining services were filtered out by the --services selection passed in WaitOptions.","commonSituations":"Script running compose wait before compose up; project name mismatch (COMPOSE_PROJECT_NAME pointing at another project); running wait after compose down; selecting a service subset where none of the selected names match running containers.","solutions":["Start the project first: docker compose up -d, then run docker compose wait.","Verify the project name matches the running stack (docker compose ls, docker ps --format '{{.Names}}').","Check spelling of services passed to the wait command/WaitOptions.Services.","Recreate removed containers if the stack was torn down accidentally (docker compose up, not just wait)."],"exampleFix":"# before\n$ docker compose down -v\n$ docker compose wait\n# Error: no containers for project \"myapp\"\n\n# after\n$ docker compose up -d\n$ docker compose wait","handlingStrategy":"validation","validationCode":"func projectHasContainers(ctx context.Context, s *composeService, name string, services []string) bool {\n\tctrs, err := s.getContainers(ctx, name, oneOffInclude, false, services...)\n\treturn err == nil && len(ctrs) > 0\n}","typeGuard":null,"tryCatchPattern":"code, err := composeService.Wait(ctx, projectName, opts)\nif err != nil {\n    if strings.Contains(err.Error(), \"no containers for project\") {\n        // run Up first, then Wait again\n    }\n    return code, err\n}","preventionTips":["Always Up before Wait in scripts; gate Wait on a successful Up exit code.","Pin COMPOSE_PROJECT_NAME explicitly in automation.","Use docker compose ls to confirm the target project is running."],"tags":["compose","wait","containers","lifecycle"],"backgroundTag":null,"analyzedSha":"ddc4b044b62e9f715212ea4143fa830fac76382f","analyzedAt":"2026-08-15T13:31:42.319Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}