docker/compose · error
could not find %s: %w
Error message
could not find %s: %w
What it means
Graph.AddEdge was called with a source vertex that was never added to the in-memory dependency graph. In practice this is the raw not-found error that resurfaces when a required depends_on target is neither an active service nor a disabled-by-profile service — i.e. it simply does not exist in the project.
Source
Thrown at pkg/compose/dependencies.go:317
// AddVertex adds a vertex to the Graph
func (g *Graph) AddVertex(key string, service string, initialStatus ServiceStatus) {
g.lock.Lock()
defer g.lock.Unlock()
v := NewVertex(key, service, initialStatus)
g.Vertices[key] = v
}
// AddEdge adds a relationship of dependency between vertices `source` and `destination`
func (g *Graph) AddEdge(source string, destination string) error {
g.lock.Lock()
defer g.lock.Unlock()
sourceVertex := g.Vertices[source]
destinationVertex := g.Vertices[destination]
if sourceVertex == nil {
return fmt.Errorf("could not find %s: %w", source, api.ErrNotFound)
}
if destinationVertex == nil {
return fmt.Errorf("could not find %s: %w", destination, api.ErrNotFound)
}
// If they are already connected
if _, ok := sourceVertex.Children[destination]; ok {
return nil
}
sourceVertex.Children[destination] = destinationVertex
destinationVertex.Parents[source] = sourceVertex
return nil
}
// Leaves returns the slice of leaves of the graph
func (g *Graph) Leaves() []*Vertex {View on GitHub (pinned to ddc4b044b6)
Solutions
- Fix the depends_on name to match a defined service
- Check which files were merged: docker compose config to see final services
- Remove the stale depends_on entry
- If it should exist behind a profile, add profiles to it (then error 191's guidance applies)
Example fix
# before
services:
api:
depends_on: [databse] # typo
# after
services:
api:
depends_on: [database] Defensive patterns
Strategy: validation
Validate before calling
// verify every depends_on source exists in the merged project
for _, svc := range project.Services {
if _, ok := project.Services[svc.Name]; !ok {
return fmt.Errorf("service %s missing from project", svc.Name)
}
} Try / catch
if err != nil && strings.Contains(err.Error(), "could not find") && strings.HasSuffix(err.Error(), api.ErrNotFound.Error()) {
// run docker compose config, fix names, re-parse and retry
} Prevention
- Run docker compose config as a pre-deploy lint step
- Rename services with grep across all compose files
- Keep depends_on lists short and reviewed in PRs
When it happens
Trigger: depends_on references a service name not defined in the (loaded) project — typo, wrong override file combination, or a service removed while depends_on remains — and it is required (default) and not profile-disabled.
Common situations: Typos in service names; compose -f overlay files that drop the depended-on service; renamed service without updating dependents; environment-variable-conditional services (profiles removed via scale).
Related errors
- service %s is required by %s but is disabled. Can be enabled
- cycle found: %s
- cannot publish compose file with local includes
- not found
- use_api_socket can't be used with a Windows Docker Engine
AI-assisted analysis of docker/compose@ddc4b044b6 (2026-08-15).
Data as JSON: /api/errors/f26417da7b905c00.
Report an issue: GitHub.