cannot extend service "web" in ...\compose.yaml: service "bse" not found — the
extends: block of web names a service, bse, that the
file does not have. Here it is a typo for base. Correct the name and the file
loads.
The first quoted name is the service that does the extending; the last one is the name
Compose looked for and did not find. Compare it with the keys under
services: and fix the spelling in extends: service:.
The error
PS> docker compose -p fix10-cs-pg config
cannot extend service "web" in C:\...\pg\compose.yaml: service "bse" not found
The command exited with code 1. The path to the test folder is shortened; nothing else in the line was changed. The file:
services:
base:
image: alpine
command: ["echo", "hello"]
web:
extends:
service: bse
Why it happens
extends copies the settings of another service into this one, so that
web gets the image and command of base without repeating them.
With no file: key under extends, Compose looked for the service
in the same file, the path it prints in the message. There is no service called
bse, so it had nothing to copy and stopped before printing any
configuration.
The message names the file it searched. In a second test the base service lived in
common.yaml and the extends block had no file:
line; Compose searched compose.yaml and gave the same message with the right
name:
PS> docker compose -p fix10-cs-pq config
cannot extend service "web" in C:\...\pq\compose.yaml: service "base" not found
So a correctly spelled name in the message points at a missing file: line;
that form is shown at the end of the fix.
The fix
services:
base:
image: alpine
command: ["echo", "hello"]
web:
extends:
service: base
PS> docker compose -p fix10-cs-pg config
name: fix10-cs-pg
services:
base:
command:
- echo
- hello
image: alpine
...
web:
command:
- echo
- hello
image: alpine
...
config printed web with the image and command it took from
base, which is the quickest way to see what extends produced.
Note that base is a full service in this file: docker compose up
started both, and both printed hello.
PS> docker compose -p fix10-cs-pg up
...
web-1 | hello
Container fix10-cs-pg-web-1 Started
...
base-1 | hello
Container fix10-cs-pg-base-1 Started
...
If the base service is only a template, docker compose up web started
web alone, and ps -a listed one container. Moving the base
service into a file of its own and naming that file under extends also
worked, and then up started only web:
services:
web:
extends:
file: ./common.yaml
service: base
PS> docker compose -p fix10-cs-pi up
...
Attaching to web-1
Container fix10-cs-pi-web-1 Starting
web-1 | hello from common.yaml
...
How it was reproduced
Two alpine services in one file, base with an image and a
command, and web with extends: service: bse, checked with
docker compose config from Windows PowerShell 5.1, then the corrected file
checked and started with docker compose up and docker compose up web,
and a second project whose web extends base from
common.yaml. Docker Compose v5.7.0, Docker Engine 29.9.3, Docker Desktop 4.99.0 on Windows (version
10.0.26300). The project names fix10-cs-pg and fix10-cs-pi are
this test's own (a third, fix10-cs-pq, with the base service in
common.yaml and no file: line, was checked with
config only); each started project was removed with docker compose down -v.
Frequently asked
- What does 'cannot extend service ... service not found' mean in Docker Compose?
- The extends block of a service names another service that Compose could not find in the file it searched. The message prints that file and the missing name; in this test it was a typo, bse for base.
- Where does docker compose extends look for the base service?
- Without a file: key under extends, it looked in the same compose file, the path printed in the message. Add file: with a path when the base service lives in another file.
- Does the base service also start when I use extends?
- In this test yes: base was a normal service in the same file, and docker compose up started both base and web. docker compose up web started web alone, and a base service kept in a separate file named under extends file: was not started.
More decoded errors in the Fixes category. A wrong
name in depends_on gives a different message; see
Docker Compose:
depends on undefined service.