Dockerode: image.push(options, callback, auth) typescript definitions are missing `auth`

Created on 18 Jan 2019  路  4Comments  路  Source: apocas/dockerode

Thanks for this library, but it's so hard to use... Like this image.push function, I can't figure out how to set it up at all... Like how to send the authToken, repositoryUrl...

Most helpful comment

For those who run across same problem the auth config has to be passed like that:

this.controller.pull('yourImage', { authConfig: auth }, (err, stream) => {
    //
});

were auth is:

       const auth = {
        username: 'u1',
        password: 'qwe',
        serveraddress: 'https://index.docker.io/v1'
      };

All 4 comments

I was able to use the info here to get the authconfig: https://github.com/apocas/dockerode/issues/448#issuecomment-384801924

Then the push is done as:

this.image = docker.getImage('repoUrl/your-image:latest');

const stream = await image.push({
       authconfig,
       tag
});

The callback and auth parameters are not required - the authconfig can be passed in as part of the options parameter.

It's important to make sure that the image.name property is prefixed with the repository url.

Although the above is true it doesn't seem to work (at least for me); here is the output I get, when trying to push the image:

[
  {
    status: 'The push refers to repository [docker.io/kghost0/node-test-img]'
  },
  { status: 'Preparing', progressDetail: {}, id: '7171d735fb9d' },
  { status: 'Preparing', progressDetail: {}, id: '37240b679bd4' },
  { status: 'Preparing', progressDetail: {}, id: '0990c60c7f3e' },
  { status: 'Preparing', progressDetail: {}, id: '6f152cfbb108' },
  { status: 'Preparing', progressDetail: {}, id: '00d2481fffd9' },
  { status: 'Preparing', progressDetail: {}, id: '8c588d32ee1b' },
  { status: 'Preparing', progressDetail: {}, id: 'b9beeac47e56' },
  { status: 'Preparing', progressDetail: {}, id: '7b6b7b7a3f95' },
  { status: 'Preparing', progressDetail: {}, id: '8b515307dc97' },
  { status: 'Preparing', progressDetail: {}, id: '0fcbbeeeb0d7' },
  { status: 'Waiting', progressDetail: {}, id: '8c588d32ee1b' },
  { status: 'Waiting', progressDetail: {}, id: 'b9beeac47e56' },
  { status: 'Waiting', progressDetail: {}, id: '7b6b7b7a3f95' },
  { status: 'Waiting', progressDetail: {}, id: '8b515307dc97' },
  { status: 'Waiting', progressDetail: {}, id: '0fcbbeeeb0d7' },
  {
    errorDetail: { message: 'denied: requested access to the resource is denied' },
    error: 'denied: requested access to the resource is denied'
  }
]

I am sure that credentials are correct as calling docker.checkAuth returns
{"IdentityToken":"","Status":"Login Succeeded"}

Any idea?

For those who run across same problem the auth config has to be passed like that:

this.controller.pull('yourImage', { authConfig: auth }, (err, stream) => {
    //
});

were auth is:

       const auth = {
        username: 'u1',
        password: 'qwe',
        serveraddress: 'https://index.docker.io/v1'
      };

@ghostbuster91

Thanks a lot for the tip!
You do have a tiny typo. It should be authconfig instead of authConfig.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

yamii picture yamii  路  5Comments

controversial picture controversial  路  3Comments

AlexanderCollins picture AlexanderCollins  路  5Comments

ehsanshekari picture ehsanshekari  路  5Comments

gaetsd picture gaetsd  路  3Comments