You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG] docker compose build <service_name> fails with "invalid reference format" when using additional_contexts #12673
When attempting to build a specific service using docker compose build <service_name>, and that service is defined using additional_contexts to stage another service image, the build process fails with either an "invalid reference format" error or, when using COMPOSE_BAKE=true, a "failed to find target" error.
Steps To Reproduce
Create a docker-compose.yaml file with the following content :
services:
base:
build:
context: .dockerfile_inline: | FROM alpinemy-service:
build:
context: .dockerfile_inline: | FROM baseadditional_contexts:
base: service:base
Run docker compose build to confirm both services build successfully.
$ docker compose build
[+] Building 2/2
✔ base Built
✔ my-service Built
Attempt to build only the dependent service:
$ docker compose build my-service
failed to solve: invalid reference format
Alternatively, try building with COMPOSE_BAKE=true:
$ COMPOSE_BAKE=true docker compose build my-service
failed to find target base
For reference, building the base service alone is done without issues:
$ docker compose build base
[+] Building 1/1
✔ base Built
Activity
ndeloof commentedon Mar 27, 2025
This indeed implies
baseMUST also be built, I'll look into this