docker-compose pull fails but docker pull works with docker-credential-gcr

940 Views Asked by At

I'm working on google container optimised OS (COS) trying to pull an image from Google Container Registry using docker-compose. I completed the the authentication using docker-credential-gcr.

Now

docker pull gcr.io/projectname/nextjs works

however

> docker-compose pull
Pulling nextjs      ... error
ERROR: for nextjs  unauthorized: You don't have the needed permissions to perform this operation, and you may have invalid credentials.
1

There are 1 best solutions below

1
On

the problem was that the docker-compose alias did not support the gcr authentication.

The following steps fixed it.

  1. Delete ~/.docker/config.json

  2. change the alias in .bashrc to:

    alias docker-compose='docker run --rm -v /var/run/docker.sock:/var/run/docker.sock -v "$PWD:$PWD" -w="$PWD" cryptopants/docker-compose-gcr'

  3. docker pull cryptopants/docker-compose-gcr

  4. docker-credential-gcr configure-docker

  5. docker-compose pull works