Description
Images referenced by a pre_start lifecycle hook are never pulled by docker compose up or docker compose pull. Only top-level service image: refs are resolved. If the hook image isn't already present locally, the hook fails at runtime with No such image, and the user must docker pull it manually. The hook image is parsed into the config (it appears in docker compose config --format json), it's just excluded from the pull set (docker compose config --images omits it).
Steps To Reproduce
compose.yml:
name: hooktest
services:
demo:
image: alpine:3.20 # present locally
command: ["sh", "-c", "echo main; sleep 2"]
pre_start:
- command: ["sh", "-c", "echo hook ran"]
image: alpine:3.19 # NOT present locally, but pullable
docker image rm alpine:3.19 2>/dev/null # ensure it's absent
docker compose config --images # lists alpine:3.20 only, not 3.19
docker compose pull # pulls 3.20 only; 3.19 still absent
docker compose up # fails
Expected
up/pull pull the hook image (respecting pull_policy), the same as service
images.
Actual
Error response from daemon: No such image: alpine:3.19
docker compose config --images and docker compose pull both omit the hook
image; it is only fetched if pulled manually.
Compose Version
Docker Environment
Client: Docker Engine - Community
Version: 29.6.1
Context: default
Debug Mode: false
Plugins:
buildx: Docker Buildx (Docker Inc.)
Version: v0.35.0
Path: /usr/libexec/docker/cli-plugins/docker-buildx
compose: Docker Compose (Docker Inc.)
Version: v5.3.1
Path: /usr/libexec/docker/cli-plugins/docker-compose
Anything else?
No response
Description
Images referenced by a
pre_startlifecycle hook are never pulled bydocker compose upordocker compose pull. Only top-level serviceimage:refs are resolved. If the hook image isn't already present locally, the hook fails at runtime withNo such image, and the user mustdocker pullit manually. The hook image is parsed into the config (it appears indocker compose config --format json), it's just excluded from the pull set (docker compose config --imagesomits it).Steps To Reproduce
compose.yml:docker image rm alpine:3.19 2>/dev/null# ensure it's absentdocker compose config --images# lists alpine:3.20 only, not 3.19docker compose pull# pulls 3.20 only; 3.19 still absentdocker compose up# failsExpected
up/pull pull the hook image (respecting pull_policy), the same as service
images.
Actual
Error response from daemon: No such image: alpine:3.19
docker compose config --images and docker compose pull both omit the hook
image; it is only fetched if pulled manually.
Compose Version
Docker Environment
Anything else?
No response