2

I created a Docker image ($DOCKER_IMAGE_NAME) using Google Cloud Build (GCB). I don't seem to be able to pull $DOCKER_IMAGE_NAME:

docker pull us-central1-docker.pkg.dev/. . ./$DOCKER_IMAGE_NAME:$DOCKER_IMAGE_TAG

#=>

Error response from daemon: Get https://us-central1-docker.pkg.dev/. . ./$DOCKER_IMAGE_NAME/v1: denied: Permission "artifactregistry.repositories.downloadArtifacts"denied on resource "projects/. . ./$DOCKER_REPOSITORY_NAME" (or it may not exist)

How can I pull $DOCKER_IMAGE_NAME?

Mike
  • 1,080
  • 1
  • 9
  • 25

3 Answers3

4

The error message seems to indicate that you need to grant permissions.

You will need to run the add-iam-policy-binding command:

gcloud projects add-iam-policy-binding $PROJECT \
--member=$MEMBER \
--role=$ROLE

where $ROLE is artifactregistry.repositories.downloadArtifacts.

See this for more information.

Mike
  • 1,080
  • 1
  • 9
  • 25
Gerb
  • 486
  • 2
  • 6
0

You also need to add role related to Artifact to your service account. Even if your service account has a owner role it wont work because GCP artifact repo has its own permissions boundary.

  • 1
    You would only need to associate a role with a service account (`$SERVICE_ACCOUNT`) if you are impersonating `$SERVICE_ACCOUNT` when `pull`ing or `push`ing a Docker image from or to GAR. Posting an answer that involves impersonating `$SERVICE_ACCOUNT` would help someone who reaches this page in search of your answer, but only if you provide more supporting details and step-by-step instructions for associating a role (e.g.,`artifactregistry.repositories.downloadArtifacts`) with `$SERVICE_ACCOUNT` using the Cloud SDK (`gcloud`), the console and/or the REST API. Thank you. – Mike May 14 '22 at 03:05
0

I saw the setup instructions from artifact registry at a later time (migrated from container registry) and it's needd to specify the region gcloud auth configure-docker europe-west1-docker.pkg.dev

PCatinean
  • 76
  • 2