{"record":{"id":"9ed426587765d789","repo":"docker/compose","slug":"no-label-q-set-on-container-q-of-compose-project","errorCode":null,"errorMessage":"no label %q set on container %q of compose project","messagePattern":"no label %q set on container %q of compose project","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"pkg/compose/ls.go","lineNumber":74,"sourceCode":"\t\t}\n\n\t\tprojects = append(projects, api.Stack{\n\t\t\tID:          project,\n\t\t\tName:        project,\n\t\t\tStatus:      combinedStatus(containerToState(containersByLabel[project])),\n\t\t\tConfigFiles: configFiles,\n\t\t})\n\t}\n\treturn projects, nil\n}\n\nfunc combinedConfigFiles(containers []container.Summary) (string, error) {\n\tconfigFiles := []string{}\n\n\tfor _, c := range containers {\n\t\tfiles, ok := c.Labels[api.ConfigFilesLabel]\n\t\tif !ok {\n\t\t\treturn \"\", fmt.Errorf(\"no label %q set on container %q of compose project\", api.ConfigFilesLabel, c.ID)\n\t\t}\n\n\t\tfor f := range strings.SplitSeq(files, \",\") {\n\t\t\tif !slices.Contains(configFiles, f) {\n\t\t\t\tconfigFiles = append(configFiles, f)\n\t\t\t}\n\t\t}\n\t}\n\n\treturn strings.Join(configFiles, \",\"), nil\n}\n\nfunc containerToState(containers []container.Summary) []string {\n\tstatuses := []string{}\n\tfor _, c := range containers {\n\t\tstatuses = append(statuses, string(c.State))\n\t}\n\treturn statuses","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/docker/compose/blob/ddc4b044b62e9f715212ea4143fa830fac76382f/pkg/compose/ls.go#L56-L92","documentation":"`docker compose ls` lists projects by reading compose labels off running containers. combinedConfigFiles merges the com.docker.compose.project.config-files label from every container in a project; if any container carrying the project label lacks the config-files label, listing that project fails. The error names the exact container ID.","triggerScenarios":"A container has label com.docker.compose.project set but no com.docker.compose.project.config-files — typically created by a very old compose version, a third-party tool that copies only some labels, or manual docker run with partial labels.","commonSituations":"Long-lived containers created before the config-files label existed; containers spawned by CI scripts that set only the project label; mixed compose versions managing the same project.","solutions":["Identify the container: docker ps --filter label=com.docker.compose.project=<project> and compare labels with docker inspect","Remove or recreate the offending container with a current compose version (docker compose up --force-recreate)","If the container is hand-made, either add the missing label or drop the project label so compose ls ignores it"],"exampleFix":"# before (manual run mimicking compose labels)\ndocker run -d --name stray --label com.docker.compose.project=myproj nginx\n\n# after (either drop the label or add the full set)\ndocker run -d --name stray nginx\n# or let compose manage it:\n# docker compose up -d --force-recreate","handlingStrategy":"validation","validationCode":"// before calling ls-style listing, verify every project container is fully labeled\nfor _, c := range containers {\n    if _, ok := c.Labels[api.ConfigFilesLabel]; !ok {\n        return fmt.Errorf(\"container %s lacks %s; recreate it via compose\", c.Id, api.ConfigFilesLabel)\n    }\n}","typeGuard":null,"tryCatchPattern":"files, err := combinedConfigFiles(containers)\nif err != nil && strings.Contains(err.Error(), \"no label\") {\n    // skip/recreate the named container instead of failing the whole listing\n}","preventionTips":["Always create project containers through a single, current compose version","Never hand-apply only some compose labels to containers","Periodically force-recreate legacy containers to refresh their label set"],"tags":["ls","labels","containers","state"],"backgroundTag":null,"analyzedSha":"ddc4b044b62e9f715212ea4143fa830fac76382f","analyzedAt":"2026-08-15T13:31:42.319Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}