Hi,
I have correctly configured the service account and its role for the GAR docker repository.
$ gcloud artifacts repositories get-iam-policy my-repo --location=asia
bindings:
- members:
- domain:my-domain.com
role: roles/artifactregistry.reader - members:
- serviceAccount:@.iam.gserviceaccount.com
role: roles/artifactregistry.writer
etag: BwYsVjoWHV4=
version: 1
$ gcloud auth configure-docker asia-docker.pkg.dev
$ gcloud auth print-access-token --impersonate-service-account @.iam.gserviceaccount.com | docker login -u oauth2accesstoken --password-stdin https://asia-docker.pkg.dev
WARNING: This command is using service account impersonation. All API calls will be executed as [@.iam.gserviceaccount.com].
Login Succeeded
I have above impersonation successful. However was never able to push image to my repository. I always get permission denied.
$ docker push asia-docker.pkg.dev/my-project/my-repo/myapp:7.6.1-20250131
The push refers to repository [asia-docker.pkg.dev/my-project/my-repo/myapp]
db45a29311e3: Preparing
a5cb861e1b73: Preparing
8fa10c0194df: Waiting
f920c5680b0b: Waiting
denied: Permission “artifactregistry.repositories.uploadArtifacts” denied on resource “projects/my-project/locations/asia/repositories/my-repo” (or it may not exist)
I had to add roles/artifactregistry.writer
to my main user account so that I can push it.
My question is does not docker command work with --impersonate-service-account?
Or am I missing something?
Regards,
Mohan