Skip to content

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

Closed

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

Activity

  1. self-assigned this
    on Jul 13, 2026
  2. hiSandog commented on Jul 15, 2026

    @hiSandog

    Because the hook image is already present in the normalized config, including it in the common image traversal seems likely to keep config --images, pull, and up consistent. A regression matrix should also cover duplicate service/hook references and hook-level pull_policy, so the fix neither pulls twice nor bypasses an explicit policy. If post-start hooks can declare images through the same schema, covering those in the traversal would prevent the behavior from remaining asymmetric.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions