Skip to content

bake: sort extra-hosts before generating build options#3789

Merged
crazy-max merged 1 commit intodocker:masterfrom
crazy-max:bake-hosts-order
Apr 14, 2026
Merged

bake: sort extra-hosts before generating build options#3789
crazy-max merged 1 commit intodocker:masterfrom
crazy-max:bake-hosts-order

Conversation

@crazy-max
Copy link
Copy Markdown
Member

fixes #3788

This change makes bake emit extra-hosts in a stable order before passing them into build options.

@thaJeztah
Copy link
Copy Markdown
Member

Is the problem that the bake file uses a map (or similar)? Curious if we have a way to preserve the order in this they are defined. It may be a corner case, but (eg) in this case, order may matter because I think the first match is used;

127.0.0.1   example.com
192.168.1.10 example.com

@crazy-max crazy-max merged commit ac8f715 into docker:master Apr 14, 2026
161 checks passed
@crazy-max crazy-max deleted the bake-hosts-order branch April 14, 2026 07:48
@blowfishpro
Copy link
Copy Markdown

@thaJeztah FWIW yes, extra-hosts is a mapping of hostname -> IP address, so it would be impossible to add duplicates, and any order information is lost when it's unmarshaled to a golang map. I took a quick look at the HCL package and it looks like it does at least at some level parse maps as an ordered sequence of key-value pairs, but I have no idea how much it would be to leverage that.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bake: extra-hosts causes build cache miss due to nondeterminstic ordering

4 participants