Search code examples
google-container-registry

How do I create a public image in Google Container Registry (GCR)?


I use GCR to store my team's private docker registry. I have a docker image that I want to make publicly visible so that multiple projects can use it / share with customers / etc.

How do I make a docker image public within Google's Container Registry?


Solution

  • 1) Create an empty cloud project to house the public registry

    2) Push something to the registry (so the bucket gets created)

    docker push gcr.io/{PROJECT_NAME}/{IMAGE_NAME}
    

    3) Make all future objects in the bucket public:

    gsutil defacl ch -u AllUsers:R gs://artifacts.{PROJECT_NAME}.appspot.com
    

    4) Make all current objects in the bucket public (eg, the image you just pushed):

    gsutil acl ch -r -u AllUsers:R gs://artifacts.{PROJECT_NAME}.appspot.com
    

    5) Make the bucket itself public (not handled by -r!):

    gsutil acl ch -u AllUsers:R gs://artifacts.{PROJECT_NAME}.appspot.com
    

    6) upload more images if desired

    Thanks to How do you make many files public in Google Cloud Storage? for providing some of the breadcrumbs here.