title: Building docker images with Jib and Gitlab-CI
body: <p>I am trying to create a pipeline where docker images are created using JIB (via a Maven Plugin) and pushed to my Gitlab Registry.</p>
  
  <p>This works fine locally as I am logged into my docker registry.</p>
  
  <pre><code>&lt;plugin&gt;
      &lt;groupId&gt;com.google.cloud.tools&lt;/groupId&gt;
      &lt;artifactId&gt;jib-maven-plugin&lt;/artifactId&gt;
      &lt;version&gt;1.0.0&lt;/version&gt;
      &lt;configuration&gt;
          &lt;allowInsecureRegistries&gt;true&lt;/allowInsecureRegistries&gt;
          &lt;from&gt;
              &lt;image&gt;dockerhost/projectgroup/alpine&lt;/image&gt;
          &lt;/from&gt;
          &lt;to&gt;
              &lt;image&gt;dockerhost/project/imagename:${project.version}&lt;/image&gt;
          &lt;/to&gt;
          &lt;container&gt;
              &lt;useCurrentTimestamp&gt;true&lt;/useCurrentTimestamp&gt;
          &lt;/container&gt;
      &lt;/configuration&gt;
  &lt;/plugin&gt;
  </code></pre>
  
  <p>Say I have a .gitlab-ci.yml which looks like:</p>
  
  <pre><code>stages:
    - build_image
  
  build_image:
    stage: build_image
  tags:
    - dev
  script: |
    mvn compile jib:build
  </code></pre>
  
  <p>Now I am getting an exception when the pipeline is triggered </p>
  
  <pre><code>Build image failed: Failed to authenticate with registry dockerhost/projectgroup/alpine because: peer not authenticated
  </code></pre>
  
  <p>I am assuming I am getting this error because I haven't run docker login -u [username] -p [password/token]</p>
  
  <p>How ever I would need a .gitlab-ci.yml which uses a docker-in-docker image to be able to run docker login within my script?</p>
  
  <p>Is there an alternative to using a docker-in-docker image to build this image on my Gitlab CI?</p>