Preparing your Docker image
The Google Container Registry accepts images built using the
docker build command. For information about
docker build, refer to the
Dockerfile Reference on the
Pushing to the registry
Before you're able to push a Docker image to any private registry, you must add the registry name and image name as a tag to the image.
Your private registry name is defined by appending your Google Cloud Platform Console project ID to one of the available gcr.io hostnames:
- us.gcr.io hosts your images in the United States.
- eu.gcr.io hosts your images in the European Union.
- asia.gcr.io hosts your images in Asia.
- gcr.io without a prefix hosts your images in the United States, but this behavior may change in a future release. To home your data in a single specific location, we recommend specifying one of the localized hostnames. Note that gcr.io and us.gcr.io are not interchangeable in your commands.
Once you've chosen a hostname, append your project ID:
If your project ID has the form
example.com:foo-bar, with Docker 1.8+ use:
To push to the registry:
Add the tag to your image:
docker tag user/example-image gcr.io/your-project-id/example-image
Then, use the
gcloudcommand-line tool to push the image to the Google Container Registry:
gcloud docker -- push gcr.io/your-project-id/example-image
The first time an image is pushed, a Google Cloud Storage bucket named
artifacts.your-project-id.appspot.com is created. You can browse this bucket
from the Google Cloud Platform Console's
Storage browser page.
This bucket should not be used for any other storage.
Deleting images from a repository
You can use the
gcloud beta container images delete
command to delete images from a Container Registry repository.