Open tsuna opened 1 year ago
docker buildx imagetools inspect --raw registry1/image:tag \ | docker buildx imagetools create -f /dev/stdin -t registry2/image:tag
Thanks for your report, this should not panic but we don't currently support reading a source from stdin. You can achieve the same behavior with:
docker buildx imagetools create registry1/image:tag -t registry2/image:tag
That worked, thanks!
Do you have a version of the output from docker buildx imagetools inspect --raw registry1/image:tag
that I could look at? Sanitized input is fine. I just want to know the shape.
My primary focus is just on getting it not to panic.
@jsternberg I repro with alpine
:
$ docker buildx imagetools inspect --raw alpine | docker buildx imagetools create -f /dev/stdin -t crazymax/alpine:test-imagetools-stdin
#1 [internal] pushing docker.io/crazymax/alpine:test-imagetools-stdin
#1 0.000 pushing to docker.io/crazymax/alpine:test-imagetools-stdin
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x11c0825]
goroutine 83 [running]:
io.(*PipeWriter).Write(...)
io/pipe.go:165
github.com/containerd/containerd/remotes/docker.(*pushWriter).Commit(0xc0006bea10, {0x0?, 0x259a3e0?}, 0x0, {0x0, 0x0}, {0xc144d49a4f0fdda9?, 0x98e55e8d?, 0x36e9360?})
github.com/containerd/containerd@v1.7.7/remotes/docker/pusher.go:452 +0x65
github.com/containerd/containerd/content.Copy({0x25bdaa0, 0xc00044dc80}, {0x25c3c08, 0xc0006bea10}, {0x259a740, 0xc000988ae0}, 0x0, {0x0, 0x0}, {0x0, ...})
github.com/containerd/containerd@v1.7.7/content/helpers.go:186 +0x3b8
github.com/docker/buildx/util/imagetools.(*Resolver).Push(0xc00044d980, {0x25bdad8?, 0xc00064e000?}, {0x25a6818, 0xc000458f00}, {{0xc000121b40, 0x39}, {0x0, 0x0}, 0x0, ...}, ...)
github.com/docker/buildx/util/imagetools/create.go:210 +0x409
github.com/docker/buildx/commands/imagetools.runCreate.func2.1({0x25aca60?, 0xc000881338})
github.com/docker/buildx/commands/imagetools/create.go:202 +0x457
github.com/docker/buildx/util/progress.Wrap({0xc000055500, 0x37}, 0xc0008812f0, 0xc000407e90)
github.com/docker/buildx/util/progress/progress.go:47 +0x2b9
github.com/docker/buildx/commands/imagetools.runCreate.func2()
github.com/docker/buildx/commands/imagetools/create.go:185 +0x285
golang.org/x/sync/errgroup.(*Group).Go.func1()
golang.org/x/sync@v0.3.0/errgroup/errgroup.go:75 +0x56
created by golang.org/x/sync/errgroup.(*Group).Go in goroutine 1
golang.org/x/sync@v0.3.0/errgroup/errgroup.go:72 +0x96
It seems to also happen on latest containerd 1.7.7 in https://github.com/containerd/containerd/blob/788f7f248a1ea5cbc3ffd5fa1be0fa3511dfe4fe/remotes/docker/pusher.go#L448. Seems like pipe writer is nil.
Looks like a combo of a couple issues:
It looks like if Write
is not called, then when Commit
is called, pipe
will be nil
. Is it possible that no content is actually being written, and it's trying to create an empty file?
Other functions on the pushWriter
seem to have nil
checks for this scenario, but Commit
does not.
Note: this looks similar in style/spirit to https://github.com/containerd/containerd/pull/8379/.
The expected argument to buildx imagetools create isn't a manifest/manifest list - it's a descriptor: https://github.com/docker/buildx/blob/7838ade9f369b164a405628a37e8dedbe91bdd10/commands/imagetools/create.go#L240-L267
Maybe we should also support manifest/manifest lists? Or at the very least, validate the output to ensure we get a reasonable descriptor (the error check there only fails on bad JSON syntax, not missing fields).
The second is what I was noticing. There seems to be a section of the code that handles different descriptor media types, but some of them seem to have their content just get discarded by that function. I was going to try to trace it out a bit more today.
At the least, we should identify that the argument is wrong. But we presently just unmarshal the JSON and go c'est la vie to whatever the result is.
Contributing guidelines
I've found a bug and checked that ...
Description
Trying to retag a multi arch image with the following approach:
Expected behaviour
A new multi arch manifest should be created that is identical to the source one
registry1/image:tag
except for its nameregistry2/image:tag
Actual behaviour
Buildx version
github.com/docker/buildx v0.11.2-desktop.5 f20ec1393426619870066baba9618cf999063886
Docker info
docker buildx imagetools inspect --raw registry1/image:tag \ | docker buildx imagetools create -f /dev/stdin -t registry2/image:tag