Search code examples
google-cloud-platformgoogle-container-registrygoogle-cloud-registry

Google Cloud Container Registry Subdirectory Create


I have an image in registry1 and want to copy it over to a registry2.

Assuming I would get that done by running this command (as stated here):

gcloud container images add-tag \ gcr.io/registry1/image1:tag1 \ gcr.io/registry2/subdirectory/image1:tag1

But I want to create a new subdirectory within the registry2 it's being moved such as:

gcr.io/registry2/subdirectory/image1:tag1 how can I create it?

Also, I'm super new to GCR. Are these called subdirectories, folders?


Solution

  • These are called repositories not folders or directories! See here.

    BTW, Google Container Registry (gcr) doesn't provide full control on these repositories, moreover, you can't assign specific IAM role/s to specific repository. to get these options, move to Artifact Registry.


    To create a repository in gcr, you need to have write access to the registry. and don't do it with gcloud, I mean don't re-tag the source image while it is still in your source repo.

    To do that, just pull the source image locally and then re-tag it using docker with the full tag

    gcr.io/registry2/repository/image1:tag1
    

    then push it and that's it! your image should be pushed to the destination repository in registry2. See Pushing an image to a registry