StefanScherer/rebase-docker-image

Invalid image parsing

Opened this issue · 5 comments

Hey @StefanScherer

I think there is something wrong with the parseImage method:

$ rebase-docker-image portainerci/portainer:develop-windows-amd64 -s "microsoft/nanoserver:sac2016" -t portainerci/portainer:develop-windows-amd64 -b mcr.microsoft.com/windows/nanoserver:1903

Retrieving information about source image portainerci/portainer:develop-windows-amd64
Retrieving information about source base image registry-1.docker.io/microsoft/nanoserver:sac2016
Retrieving information about target base image undefined/windows/nanoserver:1903
Rebasing image
##[error]C:\npm\prefix\node_modules\rebase-docker-image\index.js:542
##[error]      configTargetBase.rootfs.diff_ids
                              ^

TypeError: Cannot read property 'diff_ids' of undefined
    at rebaseBaseImages (C:\npm\prefix\node_modules\rebase-docker-image\index.js:542:31)
    at C:\npm\prefix\node_modules\rebase-docker-image\node_modules\async\dist\async.js:3880:24
    at replenish (C:\npm\prefix\node_modules\rebase-docker-image\node_modules\async\dist\async.js:1011:17)
    at iterate
##[error]e
##[error]Callback (C:\npm\prefix\node_modules\rebase-docker-image\node_modules\async\dist\async.js:995:17)
    at C:\npm\prefix\node_modules\rebase-docker-image\node_modules\async\dist\async.js:969:16
    at C:\npm\prefix\node_modules\rebase-docker-image\node_modules\async\dist\async.js:3885:13
    at Request.request [as _callback] (C:\npm\prefix\node_modules\rebase-docker-image\index.js:476:7)
    at Request.self.callback (C:\npm\prefix\node_modules\rebase-docker-image\node_modules\request\request.js:185:22)
    at Request.emit (events.js:193:13)
    at Request.<anonymous> (C:\npm\prefix\node_modules\rebase-docker-image\node_modules\request\request.js:1161:10)

For some reasons, mcr.microsoft.com/windows/nanoserver:1903 always return undefined for the org part and while this has been working for some time using undefined/windows/nanoserver:1903 as the target base image (?? for reasons unknown) this is now failing on my local environment and in our CI system.

This is pretty strange as the test seems to be here: https://github.com/StefanScherer/rebase-docker-image/blob/master/test/parseImageTest.js#L38

Idk if it's passing or not though.

Thanks @deviantony for the heads-up. I'll take a look, looks like it needs some maintenance.

One of the problems is that images from a second registry cannot really used to rebase from The digests must exit in one registry.

To be able to do that for the MCR base images is to pull them, tag them and push them to a Docker Hub repo. No worries, the actual foreign layers are still the same, it just creates the relevant metadata in Docker Hub.

rebase-docker-image portainerci/portainer:develop-windows-amd64 -s "microsoft/nanoserver:sac2016" -t portainerci/portainer:develop-windows-amd64 -b stefanscherer/nanoserver:1903

should work.

@StefanScherer thanks for the update, isn't is supposed to be supported as we can see a test case for this in the parseImageTest.js file ?

@deviantony that is only a unit test to see if all components can be extracted from the input string.
And this was my first idea to just support the mcr image names. But I found out that it would be more complicated.
This tool doesn't create missing foreign layer manifests on Docker Hub, it needs help with a real docker push.

This tool doesn't create missing foreign layer manifests on Docker Hub

Ah I see, did not understood that before. We'll have to automate that as part of our multi-arch build job.

Thanks for the update !