docker/compose · error
no container(s) found with the following name(s): %s
Error message
no container(s) found with the following name(s): %s
What it means
'docker compose generate' builds a compose project from running containers, first resolving the requested container names/IDs. If the resulting set is empty after querying by name (and by IDs), it reports the joined list of names it could not find.
Source
Thrown at pkg/compose/generate.go:62
containersByIds, err := s.apiClient().ContainerList(ctx, client.ContainerListOptions{
Filters: make(client.Filters).Add("id", options.Containers...),
All: true,
})
if err != nil {
return nil, err
}
for _, ctr := range containersByIds.Items {
if !slices.ContainsFunc(containers, func(summary container.Summary) bool {
return summary.ID == ctr.ID
}) {
containers = append(containers, ctr)
}
}
if len(containers) == 0 {
return nil, fmt.Errorf("no container(s) found with the following name(s): %s", strings.Join(options.Containers, ","))
}
return s.createProjectFromContainers(containers, options.ProjectName)
}
func (s *composeService) createProjectFromContainers(containers []container.Summary, projectName string) (*types.Project, error) {
project := &types.Project{}
services := types.Services{}
networks := types.Networks{}
volumes := types.Volumes{}
secrets := types.Secrets{}
if projectName != "" {
project.Name = projectName
}
for _, c := range containers {
// if the container is from a previous Compose application, use the existing service nameView on GitHub (pinned to ddc4b044b6)
Solutions
- List real names: docker ps -a --format '{{.Names}}' and retry with one of those
- Use the container ID instead of the name
- Verify the docker context matches where the containers run (docker context show)
- Start the container first if it exists but is stopped and you need it in the project
Example fix
# before docker compose generate web # actual name is demo-web-1 # after docker compose generate demo-web-1
Defensive patterns
Strategy: validation
Validate before calling
// verify names resolve before calling Generate
res, err := cli.ContainerList(ctx, client.ContainerListOptions{All: true})
if err != nil { return err }
byName := map[string]bool{}
for _, c := range res { byName[c.Names[0][1:]] = true; byName[c.ID[0:12]] = true }
for _, n := range wanted { if !byName[n] { return fmt.Errorf("unknown container %s", n) } } Prevention
- Query docker ps for exact names before generating
- Use container IDs to avoid project-prefix confusion
- Confirm the docker context points at the right host
When it happens
Trigger: docker compose generate <container...> where no listed name/ID matches a running or stopped container visible to the current docker context; containersByIds and name lookups both return nothing.
Common situations: Typo in container name; container removed or not yet started; wrong docker context; using compose service names instead of actual container names (e.g. missing project prefix like myproject-web-1).
Related errors
- no container found for project %q: %w
- service %q is not running container #%d
- not found
- at least one container must be specified
- unsupported format %q
AI-assisted analysis of docker/compose@ddc4b044b6 (2026-08-15).
Data as JSON: /api/errors/6263752877eb529c.
Report an issue: GitHub.