Skip to content

build: fix stdin handling when building with controller#2394

Merged
tonistiigi merged 1 commit intodocker:masterfrom
crazy-max:fix-stdin-controller
Apr 9, 2024
Merged

build: fix stdin handling when building with controller#2394
tonistiigi merged 1 commit intodocker:masterfrom
crazy-max:fix-stdin-controller

Conversation

@crazy-max
Copy link
Copy Markdown
Member

fixes #2368

When building in experimental mode we are using the controller which handles io forwarding operations, such as copying data from a reader to a writer and therefore locks stdin from being read in

magic, err := buf.Peek(archiveHeaderSize * 2)

To fix this we can skip forwarding if invoke is not used as it seems to be handled only for this case. We also have a clear condition making it not possible to use a Dockerfile or context from stdin if invoke is used:

buildx/commands/build.go

Lines 397 to 400 in 0a3e5e5

if options.invokeConfig != nil && (options.dockerfileName == "-" || options.contextPath == "-") {
// stdin must be usable for monitor
return nil, errors.Errorf("Dockerfile or context from stdin is not supported with invoke")
}

This should mitigate this issue but might need a deeper look as follow-up

@crazy-max crazy-max force-pushed the fix-stdin-controller branch from 8492eec to 02c4983 Compare April 9, 2024 12:44
@crazy-max crazy-max force-pushed the fix-stdin-controller branch from 02c4983 to ffff87b Compare April 9, 2024 13:01
@crazy-max crazy-max requested review from jedevc, ktock and tonistiigi April 9, 2024 13:16
@crazy-max crazy-max marked this pull request as ready for review April 9, 2024 13:16
Copy link
Copy Markdown
Collaborator

@ktock ktock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! LGTM

@crazy-max crazy-max added this to the v0.14.0 milestone Apr 9, 2024
@tonistiigi tonistiigi merged commit 60f4805 into docker:master Apr 9, 2024
@crazy-max crazy-max deleted the fix-stdin-controller branch April 9, 2024 16:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stdin builds hang if BUILDX_EXPERIMENTAL=1 is set

3 participants