HOWTO
- https://cloud.google.com/artifact-registry
- https://cloud.google.com/artifact-registry/docs/docker/pushing-and-pulling
See also
Authenticate against GCP via gcloud shell
dave@dave:~$ docker push gcr.io/dave-terraform/oraclelinux:7-slim
ERROR: (gcloud.auth.docker-helper) There was a problem refreshing your current auth tokens: ('invalid_grant: Bad Request', {'error': 'invalid_grant', 'error_description': 'Bad Request'})
Please run:
$ gcloud auth login
to obtain new credentials.
If you have already logged in with a different account, run:
$ gcloud config set account ACCOUNT
to select an already authenticated account to use.
The push refers to repository [gcr.io/dave-terraform/oraclelinux]
An image does not exist locally with the tag: gcr.io/dave-terraform/oraclelinux
dave@dave:~$ gcloud auth login
Your browser has been opened to visit:
https://accounts.google.com/o/oauth2/auth?....
You are now logged in as [daniel.veselka@gmail.com].
Your current project is [dave-terraform]. You can change this setting by running:
$ gcloud config set project PROJECT_ID
Configure Docker in GCP
$ gcloud auth configure-docker
Adding credentials for all GCR repositories.
WARNING: A long list of credential helpers may cause delays running 'docker build'. We recommend passing the registry name to configure only the registry you are using.
After update, the following will be written to your Docker config file located at [/home/dave/.docker/config.json]:
{
"credHelpers": {
"gcr.io": "gcloud",
"us.gcr.io": "gcloud",
"eu.gcr.io": "gcloud",
"asia.gcr.io": "gcloud",
"staging-k8s.gcr.io": "gcloud",
"marketplace.gcr.io": "gcloud"
}
}
Do you want to continue (Y/n)? Y
Docker configuration file updated.
Full list of Artifact registry
$ gcloud auth configure-docker
WARNING: Your config file at [/home/student_03_ca7dee6f1b2a/.docker/config.json] contains these credential helper entries:
{
"credHelpers": {
"asia-docker.pkg.dev": "gcloud",
"asia-east1-docker.pkg.dev": "gcloud",
"asia-east2-docker.pkg.dev": "gcloud",
"asia-northeast1-docker.pkg.dev": "gcloud",
"asia-northeast2-docker.pkg.dev": "gcloud",
"asia-northeast3-docker.pkg.dev": "gcloud",
"asia-south1-docker.pkg.dev": "gcloud",
"asia-south2-docker.pkg.dev": "gcloud",
"asia-southeast1-docker.pkg.dev": "gcloud",
"asia-southeast2-docker.pkg.dev": "gcloud",
"australia-southeast1-docker.pkg.dev": "gcloud",
"australia-southeast2-docker.pkg.dev": "gcloud",
"europe-docker.pkg.dev": "gcloud",
"europe-central2-docker.pkg.dev": "gcloud",
"europe-north1-docker.pkg.dev": "gcloud",
"europe-southwest1-docker.pkg.dev": "gcloud",
"europe-west1-docker.pkg.dev": "gcloud",
"europe-west10-docker.pkg.dev": "gcloud",
"europe-west12-docker.pkg.dev": "gcloud",
"europe-west2-docker.pkg.dev": "gcloud",
"europe-west3-docker.pkg.dev": "gcloud",
"europe-west4-docker.pkg.dev": "gcloud",
"europe-west6-docker.pkg.dev": "gcloud",
"europe-west8-docker.pkg.dev": "gcloud",
"europe-west9-docker.pkg.dev": "gcloud",
"me-central1-docker.pkg.dev": "gcloud",
"me-central2-docker.pkg.dev": "gcloud",
"me-west1-docker.pkg.dev": "gcloud",
"northamerica-northeast1-docker.pkg.dev": "gcloud",
"northamerica-northeast2-docker.pkg.dev": "gcloud",
"southamerica-east1-docker.pkg.dev": "gcloud",
"us-docker.pkg.dev": "gcloud",
"us-central1-docker.pkg.dev": "gcloud",
"us-east1-docker.pkg.dev": "gcloud",
"us-east4-docker.pkg.dev": "gcloud",
"us-east5-docker.pkg.dev": "gcloud",
"us-east7-docker.pkg.dev": "gcloud",
"us-south1-docker.pkg.dev": "gcloud",
"us-west1-docker.pkg.dev": "gcloud",
"us-west2-docker.pkg.dev": "gcloud",
"us-west3-docker.pkg.dev": "gcloud",
"us-west4-docker.pkg.dev": "gcloud"
}
}
List my own registry
$ gcloud artifacts repositories list
Listing items under project dave-terraform, across all locations.
ARTIFACT_REGISTRY
REPOSITORY FORMAT MODE DESCRIPTION LOCATION LABELS ENCRYPTION CREATE_TIME UPDATE_TIME SIZE (MB)
asia.gcr.io DOCKER STANDARD_REPOSITORY asia Google-managed key 2023-12-13T10:15:02 2023-12-13T10:15:02 0
eu.gcr.io DOCKER STANDARD_REPOSITORY europe Google-managed key 2023-12-13T10:14:54 2023-12-13T11:58:44 847.519
gcr.io DOCKER STANDARD_REPOSITORY us Google-managed key 2023-12-13T10:14:53 2023-12-13T10:14:53 0
us.gcr.io DOCKER STANDARD_REPOSITORY us Google-managed key 2023-12-13T10:14:52 2023-12-13T10:14:52 0
~$ docker push gcr.io/dave-terraform/oraclelinux:7-slim
The push refers to repository [gcr.io/dave-terraform/oraclelinux]
An image does not exist locally with the tag: gcr.io/dave-terraform/oraclelinux
dave@dave:~$ docker tag 138MB gcr.io/dave-terraform/oraclelinux:7-slim
Error parsing reference: "138MB" is not a valid repository/tag: invalid reference format: repository name must be lowercase
dave@dave:~$ docker tag 506c06ed74d4 gcr.io/dave-terraform/oraclelinux:7-slim
dave@dave:~$ docker push gcr.io/dave-terraform/oraclelinux:7-slim
The push refers to repository [gcr.io/dave-terraform/oraclelinux]
Push the Docker image to GCP container registry
$ docker push eu.gcr.io/dave-terraform/oraclelinux:7-slim
The push refers to repository [eu.gcr.io/dave-terraform/oraclelinux]
2a900b79adf5: Layer already exists
7-slim: digest: sha256:b477523e90e66d9944bb0ce9c08246c431b617bfc5997bbaa1842d009bf561bb size: 529
dave@dave:~$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
1411-weblogic-domain-in-volume latest e15b6085f27d 2 days ago 1.27GB
oracle/weblogic 14.1.1.0-generic-11 a63e1c89480e 2 days ago 1.27GB
<none> <none> a6efff1e460a 2 days ago 1.91GB
<none> <none> 74fc89d6f899 2 days ago 1.91GB
oracle/jdk 11-ol7 fea3c351284b 2 days ago 451MB
<none> <none> dcacebd8006e 2 days ago 1.14GB
gcr.io/dave-terraform/oraclelinux 7-slim 506c06ed74d4 4 weeks ago 138MB
oraclelinux 7-slim 506c06ed74d4 4 weeks ago 138MB
eu.gcr.io/dave-terraform/oraclelinux 7-slim 506c06ed74d4 4 weeks ago 138MB
Check deployed Docker images in registry via GCP console
$ gcloud container images list --repository=eu.gcr.io/dave-terraform
NAME
eu.gcr.io/dave-terraform/1411-weblogic-domain-in-volume
eu.gcr.io/dave-terraform/oracle
eu.gcr.io/dave-terraform/oraclelinux
GCP Artifact registry
docker pull \
eu.gcr.io/dave-terraform/1411-weblogic-domain-in-volume:latest