title: Docker "Login succeeded" but still cannot push to GCP private registry
body: <p>I am having issues while I am pushing my docker image to my private GCP registry.
  I created a new Service account with Owner role from Google Cloud Platform. Then I created a service key and copied the content of the json file (that I downloaded from the Service Account) in the $GCP_SERVICE_KEY variable in Gitlab CI/CD Variables.</p>
  
  <p>This my <strong>.gitlab-ci.yaml</strong> file:</p>
  
  <pre><code>image: python:3.6
  
  stages:
    - push
  
  before_script:
    - mkdir -p $HOME/.docker
    - echo "$GCP_SERVICE_KEY" &gt;&gt; "$HOME/.docker/config.json"
  
  dockerpush:
    stage: push
    image: docker:stable
    services:
      - docker:dind
    script:
      - docker build --build-arg MONGODB_URI=$MONGODB_URI -t my_image_name .
      - docker login -u _json_key --password-stdin https://gcr.io &lt; $HOME/.docker/config.json
      - docker tag my_image_name eu.gcr.io/my_project_id/my_image_name
      - docker push eu.gcr.io/my_project_id/my_image_name
  </code></pre>
  
  <p>When I check the console logs, I see "Login succeeded". But I cannot push to my GCP registry. I checked the Project ID, Roles of my user, everything seems okay. But why do I still see the "unauthorized "error?</p>
  
  <pre><code>$ docker login -u _json_key -p "$GCP_SERVICE_KEY" https://gcr.io
  WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
  Configure a credential helper to remove this warning. See
  https://docs.docker.com/engine/reference/commandline/login/#credentials-store
  
  Login Succeeded
  
  $ docker tag my_image_name eu.gcr.io/my_project_id/my_image_name   
  $ docker push eu.gcr.io/my_project_id/my_image_name   
  The push refers to repository   
  Preparing   
  Preparing   
  unauthorized: You don't have the needed permissions to perform this operation, and you may have invalid credentials.  
  To authenticate your request, follow the steps in: https://cloud.google.com/container-registry/docs/advanced-authentication
  </code></pre>