kompose: Unable to push to Google Cloud

I’ve tried every way to use Kompose, but I’ve always the same issue.

docker-compose.yml (with xxx being my google project name)

version: "3"
services:
  book-generator:
    image: gcr.io/xxx/book-generator:latest
    build: book-generator
    ports:
      - "5000:5000"
INFO Build key detected. Attempting to build and push image 'gcr.io/xxx/book-generator:latest'
INFO Building image 'gcr.io/xxx/book-generator:latest' from directory 'book-generator'
INFO Image 'gcr.io/xxx/book-generator:latest' from directory 'book-generator' built successfully
INFO Pushing image 'xxx/book-generator:latest' to registry 'gcr.io'
WARN Unable to retrieve .docker/config.json authentication details. Check that 'docker login' works successfully on the command line.: Failed to read authentication from dockercfg
INFO Authentication credentials are not detected. Will try push without authentication.
INFO Attempting authentication credentials 'gcr.io
ERRO Unable to push image 'xxx/book-generator:latest' to registry 'gcr.io'. Error: 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
FATA Error while deploying application: k.Transform failed: Unable to push Docker image for service book-generator: unable to push docker image(s). Check that `docker login` works successfully on the command line

~/.docker/config.json

{
  "auths": {
    "https://staging-k8s.gcr.io": {},
    "https://eu.gcr.io": {},
    "https://index.docker.io/v1/": {},
    "https://gcr.io": {},
    "staging-k8s.gcr.io": {},
    "asia.gcr.io": {},
    "gcr.io": {},
    "k8s.gcr.io": {},
    "us.gcr.io": {},
    "https://us.gcr.io": {},
    "https://k8s.gcr.io": {},
    "https://asia.gcr.io": {},
    "eu.gcr.io": {}
  },
  "credHelpers": {
    "gcr.io": "gcloud",
    "us.gcr.io": "gcloud",
    "eu.gcr.io": "gcloud",
    "asia.gcr.io": "gcloud",
    "staging-k8s.gcr.io": "gcloud"
  },
  "credsStore": "osxkeychain",
  "HttpHeaders": {
    "User-Agent": "Docker-Client/18.03.1-ce (darwin)"
  }
}

I tried every type of login but I’ve always the same error. What is really surprising is that a direct: gcloud docker -- push gcr.io/xxx/book-generator:latest works fine

Can you tell me how can I fix this issue ?

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 5
  • Comments: 22 (5 by maintainers)

Most upvoted comments

So I solved this on OSX by disabling the keychain password storage:

  1. rm ~/.docker/config.json
  2. in Docker for Mac preferences, untick “Securely store Docker logins in macOS keychain”
  3. restart Docker for Mac
  4. docker login

Or for glcoud and pushing to gcr: gcloud auth print-access-token | docker login -u oauth2accesstoken --password-stdin https://eu.gcr.io

now your ~/.docker/config.json should contain base64 encoded passwords. Working, not safe though!

If someone gets the keychain storage to work that would be nice…

im also able to docker login and docker push.

> gcloud auth configure-docker
gcloud credential helpers already registered correctly.

I configured the docker to be used without sudo, and use docker push rather than sudo docker push it works!

Similar thing happened to me. I’m able to push with docker docker push eu.gcr.io/XXXXXXX-####/container but from “kompose up” just hangs on "INFO Attempting authentication credentials 'gcr.io "

This is still an issue in Kompose for OSX and gcloud as of Docker Desktop 2.2.0.4. If you’ve done any googling on the topic, you’ll see @wuestkamp’s workaround, which needs a couple tweaks.

  1. Remove the credsStore key in ~/.docker/config.json

This will force docker to write the auth into the json when you use docker login. You can’t untick Securely store Docker logins in macOS keychain in the docker desktop any more – and the current credStore is no longer macOS keychain, it’s desktop.

  1. gcloud auth login Auth with gcloud (just to be explicit)
  2. gcloud auth print-access-token | docker login -u oauth2accesstoken --password-stdin https://eu.gcr.io

You should see this:

WARNING! Your password will be stored unencrypted in /Users/andrew/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store

Login Succeeded

It would be super great to have Kompose use the credential helper properly! /reopen

So I solved this on OSX by disabling the keychain password storage:

  1. rm ~/.docker/config.json
  2. in Docker for Mac preferences, untick “Securely store Docker logins in macOS keychain”
  3. restart Docker for Mac
  4. docker login

Or for glcoud and pushing to gcr: gcloud auth print-access-token | docker login -u oauth2accesstoken --password-stdin https://eu.gcr.io

now your ~/.docker/config.json should contain base64 encoded passwords. Working, not safe though!

If someone gets the keychain storage to work that would be nice…

@wuestkamp manually update to the new version of Docker Compose. You can get it here. Follow the guideline for manually installing/updating it. Even though the text says that you get the latest one if you are using Docker Desktop for Mac I did not have v1.24 of Docker Compose. Yes I did try checking for updates.

After having updated, when I execute e.g. docker-compose up --build I would get a more descriptive error. Suggesting me to actually execute gcloud auth login or set the creds with gcloud to the set I wanted to use. After having done one of the two I was now able to execute the docker-compose cmd I wanted to.

I hope the above helps.

@hangyan yes, docker login and docker push works well.