Unauthorized: authentication required when using docker push

build-image
nodejs
docker

#1

URGENT
I didn’t change anything. But started getting the following error when I’m trying to push the docker image even though it is passing at docker login. I’m using google cloud.

  Error: Command failed: docker push docker.io/****
    unauthorized: authentication required

I’m using below function, which I’m using by node deploy.js

function push (cb, attempt = 0) {
  exec(`docker push docker.io/***:${TAG}`, (err, stdout, stderr) => {
    if (err) {
      attempt++
      console.error(err)

      if (attempt > 3) {
        if (stderr) console.log(stderr)
        if (stdout) console.log(stdout)
        throw err
      } else {
        return setTimeout(function () {
          return push(cb, attempt)
        }, 1000)
      }
    }
    console.log(`pushed: docker.io/***:${TAG}`)
    return cb(null)
  })
}


#2

The issue was from Dockerhub. The private repos were not available due to missed payment. As soon as we paid, it started working.


#3