-
Notifications
You must be signed in to change notification settings - Fork 618
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[nerdctl build] Set default output type=image #3604
base: main
Are you sure you want to change the base?
Conversation
2d18366
to
01db27a
Compare
I need to work through this later, but I'm unclear how the current code works on non-Windows. How do those platforms distinguish a tar file from log output on stdout? They shouldn't be passing through a termInal on the way, the terminal is where nerdctl's stdio is connected, so I don't understand what's different on Windows. |
Hey @TBBle |
Still investigating the issue. This is a temp fix and the PR is WIP (may and may not be the final solution).
|
Deeply confused about this.
This does not make any sense. Now suspecting buildctl might be the problem. |
buildctl "output" goes to stderr. Is it the case on windows?
or
|
01db27a
to
1e7bbf4
Compare
1e7bbf4
to
80dc420
Compare
output = "type=docker" | ||
// https://github.com/moby/buildkit?tab=readme-ov-file#output | ||
// type=image is the native type for containerd | ||
output = "type=image" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Default to type=image
instead of type=docker
. See #3604 (comment)
cc @profnandaa
if err != nil { | ||
if r.N == 0 { | ||
// Avoid confusing "unrecognized image format" | ||
return errors.New("no image was built") | ||
return fmt.Errorf("no image was built: %w", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make the error more descriptive by adding the actual error
9581c2c
to
14392ff
Compare
- Use default image name only when user has not specified one Signed-off-by: Christine Murimi <[email protected]>
14392ff
to
f4728b4
Compare
Does this introduce a requirement that buildkit is configured to use the containerd worker? Or is that already a requirement for using |
…amor/fix-build-with-tty
@@ -89,17 +89,17 @@ CMD ["echo", "nerdctl-build-test-string"]`, testutil.CommonImage) | |||
Expected: test.Expects(0, nil, test.Equals("nerdctl-build-test-string\n")), | |||
}, | |||
{ | |||
Description: "Successfully build with output docker, name cannot be used", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@apostasie I've removed this test for now. I may be missing something. What is this testing?
@TBBle In Windows, containerd-worker is the default. There is ongoing work to support oci-worker on Windows. On Linux environments, [oci-worker is the default].(https://github.com/moby/buildkit/blob/5cd5a63de5d37512c24f20085607509b749df762/README.md#linux-setup) Additionally, with the shift from docker to containerd, we then should switch to using References:
@AkihiroSuda @jsturtevant What do you think? |
The OCI worker still has to be supported |
PR Description
Linked Issue: containerd/nerdctl#3629
This PR resolves #3629 for
nerdctl build
command when passed with:--progress auto
,--progress tty
, or--progress
flag is not specified (which then defaults to--progress auto
)--output
flag is not specifiedExample:
nerdctl build -t <TAG> --file .\Dockerfile .
Background
The issue occurs because the build progress output and the tarball are both sent to stdout on WIndows.
Solution
nerdctl/pkg/cmd/builder/build.go
Line 216 in 0d7dc8e
When a user does not specify the
--output
flag, we default it to usetype=image
instead oftype=docker
because the image is actually uploaded to containerd image store. According to buildctl documentation,type=image
is the native type for containerd.Additional tasks
Not included in this PR
type=oci
nerdctl/pkg/cmd/builder/build.go
Line 220 in 0d7dc8e
type=docker
Currenly fails with
archive/tar: invalid tar header
moby/buildkit/issues/5528References