StefanScherer / rebase-docker-image

Rebase a dockerized Windows app to a newer Windows Docker base image.
https://stefanscherer.github.io/poc-build-images-for-1709-without-1709/
MIT License
10 stars 2 forks source link

What am I doing wrong? #2

Closed artisticcheese closed 3 years ago

artisticcheese commented 6 years ago
PS C:\Users\cloudadmin> $env:DOCKER_USER="artisticcheese@gmail.com"
PS C:\Users\cloudadmin> $env:DOCKER_PASS="mypassword"
PS C:\Users\cloudadmin> & $env:AppData\npm\rebase-docker-image.cmd  --src "artisticcheese/whoami:nanolts-2018060527"  --target "artisticcheese/whoami:nano1709-1"   --targetbase microsoft/nanoserver:1709
Retrieving information about source image artisticcheese/whoami:nanolts-2018060527
Retrieving information about source base image microsoft/nanoserver:10.0.14393.2248
Retrieving information about target base image microsoft/nanoserver:1709
Rebasing image
Pushing target image artisticcheese/whoami:nano1709-1
Error: Error: no auth mechanism defined
    at Auth.onRequest (C:\Users\cloudadmin\AppData\Roaming\npm\node_modules\rebase-docker-image\node_modules\request\lib\auth.js:132:32)
    at Request.auth (C:\Users\cloudadmin\AppData\Roaming\npm\node_modules\rebase-docker-image\node_modules\request\request.js:1349:14)
    at Request.init (C:\Users\cloudadmin\AppData\Roaming\npm\node_modules\rebase-docker-image\node_modules\request\request.js:375:10)
    at new Request (C:\Users\cloudadmin\AppData\Roaming\npm\node_modules\rebase-docker-image\node_modules\request\request.js:128:8)
    at request (C:\Users\cloudadmin\AppData\Roaming\npm\node_modules\rebase-docker-image\node_modules\request\index.js:53:10)
    at beginUpload (C:\Users\cloudadmin\AppData\Roaming\npm\node_modules\rebase-docker-image\index.js:463:3)
    at C:\Users\cloudadmin\AppData\Roaming\npm\node_modules\rebase-docker-image\node_modules\async\dist\async.js:3866:24
    at replenish (C:\Users\cloudadmin\AppData\Roaming\npm\node_modules\rebase-docker-image\node_modules\async\dist\async.js:998:17)
    at iterateeCallback (C:\Users\cloudadmin\AppData\Roaming\npm\node_modules\rebase-docker-image\node_modules\async\dist\async.js:983:17)
    at C:\Users\cloudadmin\AppData\Roaming\npm\node_modules\rebase-docker-image\node_modules\async\dist\async.js:958:16
StefanScherer commented 6 years ago

Hm the command looks good. But some metadata of the images seem to be different than the ones I used writing this tool.

I tried to look closer into your source image with

$ docker run stefanscherer/winspector artisticcheese/whoami:nanolts-2018060527
Retrieving information about source image artisticcheese/whoami:nanolts-2018060527
Image name: artisticcheese/whoami
Tag: nanolts-2018060527
Number of layers: 11
Schema version: 2
Architecture: undefined
Created: undefined with Docker undefined on undefined undefined
Sizes of layers:
  sha256:bce2fbc256ea437a87dadac2f69aabd25bed4f56255549090056c1131fad0277 - 252691002 byte
  sha256:58518d66816013a4ae1ec4ef454beff05e957b515f6c364b45fe76b8a527e022 - 164879119 byte
  sha256:8ac45f8295116b98e1b4d2eb0c2055c52011bdc42ba239b0731aef5ffff9576d - 957 byte
  sha256:ca525a162a258bf3f8eed23508e54de70c6f07951f61cb582e28d59079de096b - 969 byte
  sha256:9483673b14d73f3e9a034efe1bb0611f1397bdcb66d63cfe78ea3d83015c3593 - 31389775 byte
  sha256:6d365effe51538e1ec8a4b54d6bfd9ed582b2db0b0078e618a1de86e0addff05 - 843423 byte
  sha256:080160b182adfff9148d2b75eefea61ae1190e771a02c07cf23a88d7aa133d5b - 961 byte
  sha256:3fb40e134aa2824877463a62354e9eac3930939aed4af6055a466b10d5441a6f - 40389 byte
  sha256:63f3eb75e99088e42499851fb3b33744346dbc2627a7e1fe8d89956dfd2e4388 - 954 byte
  sha256:b81ba4420463f098d2599f91a72fc2f53d51219ba3c0159f9f4318a77f9ce2dd - 954 byte
  sha256:9e85157288c5c2b8d711134ce092f7fedad028ad63940c0b84847216db05089f - 948 byte
Total size (including Windows base layers): 449849451 byte
Application size (w/o Windows base layers): 32279330 byte
Windows base image used:
  It does not seem to be a Windows image
  microsoft/nanoserver:10.0.14393.447 full
  sha256:58518d66816013a4ae1ec4ef454beff05e957b515f6c364b45fe76b8a527e022 - unknown Windows layer
History:
/code/index.js:210
  configSource.history.forEach(hist => {
                       ^

TypeError: Cannot read property 'forEach' of undefined
    at inspectSourceImage (/code/index.js:210:24)
    at /code/node_modules/async/dist/async.js:3853:24
    at replenish (/code/node_modules/async/dist/async.js:946:17)
    at iterateeCallback (/code/node_modules/async/dist/async.js:931:17)
    at /code/node_modules/async/dist/async.js:906:16
    at /code/node_modules/async/dist/async.js:3858:13
    at Request.request [as _callback] (/code/index.js:159:7)
    at Request.self.callback (/code/node_modules/request/request.js:186:22)
    at emitTwo (events.js:126:13)
    at Request.emit (events.js:214:7)

but there are also errors inspecting it. When I do this for an image I created it should look like this:

$ docker run stefanscherer/winspector stefanscherer/whoami:windows-amd64-1.7.0
Retrieving information about source image stefanscherer/whoami:windows-amd64-1.7.0
Image name: stefanscherer/whoami
Tag: windows-amd64-1.7.0
Number of layers: 5
Schema version: 2
Architecture: amd64
Created: 2018-05-15T22:10:32.0640827Z with Docker 17.06.1-ee-2 on windows 10.0.14393.2248
Sizes of layers:
  sha256:bce2fbc256ea437a87dadac2f69aabd25bed4f56255549090056c1131fad0277 - 252691002 byte
  sha256:58518d66816013a4ae1ec4ef454beff05e957b515f6c364b45fe76b8a527e022 - 164879119 byte
  sha256:5c129632288d2c8e222b85aa791aba057b2ec88c56fefadc0b4da3faab4ed2f4 - 2288253 byte
  sha256:5f6b66065a39725a0f0370d59ddfecf5d238d688c12214c3387c9d22a1ed2c84 - 948 byte
  sha256:1f47e0983811831d0f6981ded16a6e66348ff8b60c353de2b807b90759a8c2c5 - 936 byte
Total size (including Windows base layers): 419860258 byte
Application size (w/o Windows base layers): 2290137 byte
Windows base image used:
  microsoft/nanoserver:10.0.14393.447 full
  sha256:58518d66816013a4ae1ec4ef454beff05e957b515f6c364b45fe76b8a527e022 - unknown Windows layer
History:
   Apply image 10.0.14393.0
   Install update 10.0.14393.2248
   COPY file:b43b74043e865ec55e5c45f8e54013333ed4e8b6775b93e7ab25f1493b641aed in \http.exe 
   EXPOSE 8080/tcp
   CMD ["\\http.exe"]

This doesn't mean you did something wrong. But my tools just cannot read the metadata as they have unexpected or different data.

How did you create the source image? The OS version and Docker version of the docker build might be interesting. Is it done in VSTS? Mine were built on AppVeyor as you my know and there's a very 'normal' installation with Docker 17.06.1-ee-2 on a Windows Server 2016.

Really weird.

StefanScherer commented 6 years ago

Yeah seems the same problem with rebase-docker-image tool as in winspector tool. The missing retrieved metadata is making trouble running through the code.

On my side I have a slightly different error

$ rebase-docker-image  --src "artisticcheese/whoami:nanolts-2018060527"  --target "stefanscherer/whoami:nano1709-1"   --targetbase microsoft/nanoserver:1709
Retrieving information about source image artisticcheese/whoami:nanolts-2018060527
Retrieving information about source base image microsoft/nanoserver:undefined
/Users/stefan/.nvm/versions/node/v8.9.3/lib/node_modules/rebase-docker-image/index.js:405
      }/blobs/${manifestSourceBase.config.digest}`,
                                          ^

TypeError: Cannot read property 'digest' of undefined
    at getConfigOfSourceBaseImage (/Users/stefan/.nvm/versions/node/v8.9.3/lib/node_modules/rebase-docker-image/index.js:405:43)
    at /Users/stefan/.nvm/versions/node/v8.9.3/lib/node_modules/rebase-docker-image/node_modules/async/dist/async.js:3866:24
    at replenish (/Users/stefan/.nvm/versions/node/v8.9.3/lib/node_modules/rebase-docker-image/node_modules/async/dist/async.js:998:17)
    at iterateeCallback (/Users/stefan/.nvm/versions/node/v8.9.3/lib/node_modules/rebase-docker-image/node_modules/async/dist/async.js:983:17)
    at /Users/stefan/.nvm/versions/node/v8.9.3/lib/node_modules/rebase-docker-image/node_modules/async/dist/async.js:958:16
    at /Users/stefan/.nvm/versions/node/v8.9.3/lib/node_modules/rebase-docker-image/node_modules/async/dist/async.js:3871:13
    at Request.request [as _callback] (/Users/stefan/.nvm/versions/node/v8.9.3/lib/node_modules/rebase-docker-image/index.js:395:7)
    at Request.self.callback (/Users/stefan/.nvm/versions/node/v8.9.3/lib/node_modules/rebase-docker-image/node_modules/request/request.js:186:22)
    at emitTwo (events.js:126:13)
    at Request.emit (events.js:214:7)

When I give the rebase tool a hint which base image the source image uses with --srcbase then there is an error copyin os.version metadata. Seem like there is some authentication problem using it from my account.

$ rebase-docker-image  --src "artisticcheese/whoami:nanolts-2018060527"  --target "stefanscherer/whoami:nano1709-1"   --srcbase microsoft/nanoserver:sac2016 --targetbase microsoft/nanoserver:1709
Retrieving information about source image artisticcheese/whoami:nanolts-2018060527
Retrieving information about source base image microsoft/nanoserver:sac2016
Retrieving information about target base image microsoft/nanoserver:1709
Rebasing image
/Users/stefan/.nvm/versions/node/v8.9.3/lib/node_modules/rebase-docker-image/index.js:495
  configTarget['os.version'] = configTargetBase['os.version'];
                             ^

TypeError: Cannot create property 'os.version' on string '<?xml version="1.0" encoding="UTF-8"?>
<Error><Code>InvalidArgument</Code><Message>Only one auth mechanism allowed; only the X-Amz-Algorithm query parameter, Signature query string parameter or the Authorization header should be specified</Message><ArgumentName>Authorization</ArgumentName>
...
artisticcheese commented 6 years ago

I used VSTS hosted agent to build it. But image below I built by hand. Is it also showing as having issues?artisticcheese\whoami:test Code is here https://github.com/artisticcheese/artisticcheesecontainer/tree/master/whoami