Skip to content

[BUG] Docker compose up/pull does not pull images referenced in pre_start lifecycle hooks #13924

Description

@mu-adnan

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

5.3.0

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

Metadata

Metadata

Assignees

Labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions