Skip to content

Support time-based image pull policies (Daily / Weekly / Every(duration)) in ImagePullPolicy #19619

Description

Is there an existing issue for this?

  • I have searched the existing issues

Is your feature request related to a problem? Please describe the problem.

Summary

ImagePullPolicy currently exposes only Default, Always, Missing, and Never. There is no way to express a periodic refresh. Docker Compose already supports exactly this via time-based pull_policy values (daily, weekly, every_<duration>). This issue requests parity in Aspire's ImagePullPolicy.

Motivation

A very common local-dev / CI pattern is a container pinned to a mutable tag such as :latest that an upstream pipeline rebuilds roughly once a day:

builder.AddContainer("mock", "registry.example.com/org/mock-service", "latest")
    .WithLifetime(ContainerLifetime.Session);

Today the available options are both unsatisfying:

  • Missing / Default — the cached :latest is reused forever and silently goes stale; you never pick up the daily rebuild unless you manually docker pull or prune.
  • Always — re-pulls on every aspire run / startup. That adds pull latency to every launch and fails hard with no network (see Keeping referenced containers automatically up to date #10719), even though a day-old cached image would have been perfectly fine.

What's actually wanted is "keep it reasonably fresh, but don't pay the pull cost on every start".

What Docker Compose already does

The Compose spec supports time-based pull policies:

  • daily: check the registry if the last pull was more than 24h ago
  • weekly: same, for 7 days
  • every_<duration>: every_12h, every_2d, every_1h30m

Docs: https://docs.docker.com/reference/compose-file/services/#pull_policy

Because Aspire maps WithImagePullPolicy(...) onto the generated Compose pull_policy when publishing to a Docker Compose environment, the current enum can't even emit these values today.

Describe the solution you'd like

Proposed API

Add time-based members / a factory to ImagePullPolicy, e.g.:

// convenience presets
builder.AddContainer("mock", "registry.example.com/org/mock-service", "latest")
    .WithImagePullPolicy(ImagePullPolicy.Daily);

builder.AddContainer("mock", "registry.example.com/org/mock-service", "latest")
    .WithImagePullPolicy(ImagePullPolicy.Weekly);

// arbitrary interval
builder.AddContainer("mock", "registry.example.com/org/mock-service", "latest")
    .WithImagePullPolicy(ImagePullPolicy.Every(TimeSpan.FromHours(12)));

Semantics: before creating the container, if the locally cached image's pull/creation time is older than the interval, pull; otherwise reuse the cache.

Relationship to existing issues

Additional context

Aspire ImagePullPolicy members as of today: Default, Always, Missing, Never

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-app-modelIssues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplicationarea-orchestratorneeds-area-labelAn area label is needed to ensure this gets routed to the appropriate area ownerstriage:bot-seenAspire triage bot has seen this issue

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions