docker/compose · warning

no label %q set on container %q of compose project

Error message

no label %q set on container %q of compose project

What it means

`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.

Source

Thrown at pkg/compose/ls.go:74

		}

		projects = append(projects, api.Stack{
			ID:          project,
			Name:        project,
			Status:      combinedStatus(containerToState(containersByLabel[project])),
			ConfigFiles: configFiles,
		})
	}
	return projects, nil
}

func combinedConfigFiles(containers []container.Summary) (string, error) {
	configFiles := []string{}

	for _, c := range containers {
		files, ok := c.Labels[api.ConfigFilesLabel]
		if !ok {
			return "", fmt.Errorf("no label %q set on container %q of compose project", api.ConfigFilesLabel, c.ID)
		}

		for f := range strings.SplitSeq(files, ",") {
			if !slices.Contains(configFiles, f) {
				configFiles = append(configFiles, f)
			}
		}
	}

	return strings.Join(configFiles, ","), nil
}

func containerToState(containers []container.Summary) []string {
	statuses := []string{}
	for _, c := range containers {
		statuses = append(statuses, string(c.State))
	}
	return statuses

View on GitHub (pinned to ddc4b044b6)

Solutions

  1. Identify the container: docker ps --filter label=com.docker.compose.project=<project> and compare labels with docker inspect
  2. Remove or recreate the offending container with a current compose version (docker compose up --force-recreate)
  3. If the container is hand-made, either add the missing label or drop the project label so compose ls ignores it

Example fix

# before (manual run mimicking compose labels)
docker run -d --name stray --label com.docker.compose.project=myproj nginx

# after (either drop the label or add the full set)
docker run -d --name stray nginx
# or let compose manage it:
# docker compose up -d --force-recreate
Defensive patterns

Strategy: validation

Validate before calling

// before calling ls-style listing, verify every project container is fully labeled
for _, c := range containers {
    if _, ok := c.Labels[api.ConfigFilesLabel]; !ok {
        return fmt.Errorf("container %s lacks %s; recreate it via compose", c.Id, api.ConfigFilesLabel)
    }
}

Try / catch

files, err := combinedConfigFiles(containers)
if err != nil && strings.Contains(err.Error(), "no label") {
    // skip/recreate the named container instead of failing the whole listing
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


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