Skip to content

Bake should not allow multiple cache outputs of the same name #3819

@kyle-basis

Description

@kyle-basis

Description

Currently, bake allows for multiple targets to output to the same cache target. When you do so, the result is non-deterministic and mostly results in your build never caching properly, and it being a total mystery why. I've done this two different ways:

  1. By accident, having a somewhat complex bake file/Dockerfile, and not noticing I did a bad copy paste on a cache name
  2. In a Multiplatform build (see Best way to cache multi-stage + multi-platform image builds #1382) This one might already be fixed, or may only be an issue with GHA output, I'm still debugging some cache busting issues. If it's supposed to be fixed, adding validation that we never output cache targets of the same name would be neat.

I'd also say that probably one shouldn't be allowed to name two regular output targets of the same name in the same build, but I haven't actually tried to see if bake lets you.

Is there an actual use case for this? Otherwise it seems like a footgun, and should error. If there's a desire not to break existing "working" bakefiles, could go with a warning for some number of releases, first.

I've been working a lot with various docker internals for my work on clipper.dev, happy to put up a PR to fix this if it would be accepted.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions