Search code examples
bamboodocker-registryjib

How can the jib maven plugin authenticate to docker hub and publish to ECR?


I've been using the jib-maven-plugin to build docker tarball images from a bamboo container instance which is then pushed to an ECR.

I have the following server instance in ~/.m2/settings.xml which resides in the builder image:

<server>
  <id>registry.hub.docker.com</id>
  <username>${docker.hub.username}</username>
  <password>${docker.hub.password}</password>
</server>

This I then call with maven:

mvn -Ddocker.hub.username=${bamboo.docker_hub_username} \
    -Ddocker.hub.password=${bamboo.docker_hub_password} \
    package deploy

where deploy is associated with the buildTar jib execution goal.

This however does not seem to use my account when pulling images from dockerhub which I need for amazoncoretto.

I recieve the following error from jib.

Failed to execute goal com.google.cloud.tools:jib-maven-plugin:2.6.0:buildTar (docker-package) on project auth-server: 429 Too Many Requests
{
  "errors": [
    {
      "code": "TOOMANYREQUESTS",
      "message": "You have reached your pull rate limit. You may increase the limit by authenticating and upgrading: https://www.docker.com/increase-rate-limit"
    }
  ]
}

Solution

  • I have found a workaround by utilising the jib jib.from.auth.username and jib.from.auth.password system parameters.

    mvn -Djib.from.auth.username=${bamboo.docker_hub_username} \
        -Djib.from.auth.password=${bamboo.docker_hub_password} \
        package deploy