published fresh until

Docker Compose: depends on undefined service—why?

Summary As of October 2026, compare dependency service names and network references in the selected Compose files and profiles; no universal network repair is established (checked 2026-10-28). Start with docker compose config --quiet.

Not for no configuration file provided, see docker-compose-no-configuration-file-provided-file-path

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

service %q depends on undefined service %q: %w

Docker Compose rejects a dependency reference while validating the application model.

Do first: run docker compose config --quiet with the same -f file selections and profiles as the failing invocation.

Evidence status: official validation code establishes the missing-reference checks and docs describe services and networks; historical reports show related failures, but these steps have not been run here (checked 2026-10-28).

Not for: Docker Compose no configuration file provided; see docker-compose-no-configuration-file-provided-file-path.

How to inspect and correct the model

1. Keep the original file selections and profiles. Use docker compose config --quiet to validate without printing the resolved model. The command merges selected files and resolves the model; --quiet validates only. Config command (checked 2026-10-28). 2. For an undefined service, compare the literal depends_on entry with the keys under services in those files. The specification describes dependencies between services. Reference the intended declared service, or include its actual defining file; do not invent an empty service just to silence validation. Compose specification (checked 2026-10-28). 3. Check profile selection if the named service is declared but inactive. The official guide documents --profile and explains that profiled services are selectively enabled. Match the intended application's profiles rather than enabling unrelated services indiscriminately. Profiles guide (checked 2026-10-28). 4. For an undefined network, compare the service's networks reference with the top-level networks keys in the selected files. This is a diagnostic comparison: the cited primary documentation describes declarations but gives no explicit fix for this exact error. Determine whether the intended declaration or file is absent before proposing a change. Network reference (checked 2026-10-28). 5. Untested experiment: make the smallest service-name, file-selection, profile or network-declaration change supported by that comparison. Repeat docker compose config --quiet with the intended file and profile selections; check that validation succeeds and that the selected declarations match the intended application. Validation passing establishes model consistency, not container readiness or successful communication.

Diagnostic: refers to undefined network

The official templates are service %q depends on undefined service %q: %w and service %q refers to undefined network %s: %w. %q formats a quoted name; %s formats the network name; %w wraps an error. These are source templates, with names supplied when the error is emitted. The historical reports below illustrate related messages whose formatting may differ by implementation. compose-go validation source (checked 2026-10-28).

Which check applies?

SymptomInspect firstWhat is established
Undefined dependency serviceDependency name, selected files, active profilesThe validator failed to obtain that referenced service
Undefined networkService network key versus top-level network mapThe validator did not find that network key
Config passes but app fails laterRuntime logs and service readinessThis is a different diagnostic stage

The first two rows follow the validation code above. They do not prove why a user's effective model lost a definition. Current dependency options are documented in the services reference (checked 2026-11-24).

Public evidence

  • ShahimEssaid, Compose issue #10901, 2023-08-15 (checked 2026-10-28): “I was configuring one service per compose file”. The author reported an undefined dependency using optional dependency settings with a completion condition. This is historical behavior, not evidence that the same bug remains in current builds.
  • metasoarous, compose-cli issue #1308, 2021-02-15 (checked 2026-10-28): “service "XXX" refers to undefined network default: invalid compose project”. The report compared two Compose implementations and was closed through a linked change. It does not establish a present-day missing-network remedy.

What to test

Validate each intended file/profile combination, including the one used by CI. Confirm that required dependency names and network declarations belong to that model. Then test application startup separately. A passing configuration check does not establish that a database is ready to accept connections.

Pitfalls

Editing a file omitted from the invocation; confusing a container name with a service key; treating a disabled dependency as a misspelling; using --no-consistency to hide the error. The config reference explicitly warns that bypassing consistency checks can produce invalid output.

A prompt to give your agent

Read the linked Compose config, profiles and specification pages before proposing a patch. Given these Compose files and the exact failing command, list selected files, enabled profiles, dependency service names and network references. Start with config --quiet. Label a proposed correction “Untested experiment”; check it with config --quiet using the intended files and profiles and confirm the declarations match the intended application. Do not invent a network fix, add dummy services, disable consistency checks or start containers merely to make validation pass.

Limits

No Compose project was executed. Error formats come from compose-go's moving main branch (checked 2026-10-28); individual released implementations can differ. The network docs do not establish a single repair for every undefined-network message. The two public reports are old and support occurrence of the symptoms, not current prevalence or a current regression.

Started from a post by @ShahimEssaid, packaged by the editor. Original post

Subjects

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# Docker Compose: depends on undefined service—why?
Summary: As of October 2026, compare dependency service names and network references in the selected Compose files and profiles; no universal network repair is established (checked 2026-10-28). Start with docker compose config --quiet.
Copy for agent
get the whatworks thread docker-compose-undefined-service-network-validate-model and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread docker-compose-undefined-service-network-validate-model
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks