[GCP] Until you push the local Docker image to the Container Registry

Overview

Work to push the container image developed and built in the local environment from the local to the repository of "Container Registry"

reference

https://cloud.google.com/container-registry/docs/pushing-and-pulling#push_the_tagged_image_to

procedure

1. gcloud settings

  1. Install the gcloud command in your local environment
    • https://cloud.google.com/sdk/docs/quickstart-macos?hl=ja
  2. Initial setting
    • gcloud init

2. Create a service account for Push / Pull of the image

When using your own user account, if the projects are linked in various ways, you are afraid of making a mistake in selecting the project ID, so create a dedicated service account.

  1. Create a service account --Working on the console
  2. Authority settings --The container image of "Container Registry" is managed by Cloud Storage, and the authority is just to grant the "Storage administrator" authority of Cloud Storage.
    • https://cloud.google.com/container-registry/docs/access-control#grant https://cloud.google.com/sdk/docs/authorizing?hl=ja#authorizing_with_a_service_account
  3. Create a key for the service account and set up authentication locally
    • gcloud auth activate-service-account
    • https://cloud.google.com/sdk/docs/authorizing?hl=ja#authorizing_with_a_service_account

3. Docker authentication settings

Settings for using gcloud as a Docker authentication helper

  1. Run gcloud auth configure-docker locally

4. Push Docker image

  1. Tag the local image with the registry name --Naming convention: [HOSTNAME] / [PROJECT-ID] / [IMAGE] -[HOSTNAME]: Select from the following. This will determine where to save the image. --gcr.io hosts the image in a data center in the United States, but its location is subject to change in the future. --us.gcr.io is a storage bucket that hosts the image in a data center in the United States, but is independent of the image hosted by gcr.io. --eu.gcr.io hosts the image in the European Union. --asia.gcr.io hosts the image in a data center in Asia. -[PROJECT-ID]: Project ID of the target Google Cloud project -[IMAGE]: Name of container image --Tagging command: docker tag [local image name or image ID] [registry name]: [tag (latest if not specified)]
  2. Push --docker push [registry name]: [tag (latest if not specified)]

If you push a new one, a repository will be created on the Container Registry.

Recommended Posts

[GCP] Until you push the local Docker image to the Container Registry
Steps to push Docker image to GitHub Container Registry (ghcr.io)
Docker push to GitHub Container Registry (ghcr.io)
Minimal Workflow to push Docker image to Github Container Registry with Github Actions
Push the image to docker hub using Jib
Push the Docker Image distributed by Docker Hub to Google Container Registry and start the VM based on that Image
Test, build, and push your Docker image to GitHub Container Registry using GitHub Actions
Until you push to Github
Push Docker images from GitHub Actions to GitHub Container Registry
Until you build the docker environment and start / stop the Ubuntu container
How to check the logs in the Docker container
Introduce docker to the application you are creating
Change the location folder of Docker image & container
Until you run a Java program with the AWS SDK local to Windows
Until you try running Apache Kafka with docker image
How to deploy to Heroku from a local docker image
I can't find the docker image after updating to docker desktop 2.4.0.0
[Introduction to Docker] ~ The shortest explanation until starting jupyter lab ~
Wait for the container service to start with docker healthcheck
[Personal notes] How to push a Docker image to GitHub Packages
[Docker] How to access the host from inside the container. http://host.docker.internal:
How to solve the problem that you can not pull image from docker hub with Minikube
When you want to ZIP download the image data saved locally
[Rails + Webpacker] I want to use images of assets! Until you can view the image in Vue.js
Introduction to Linux Container / Docker (Part 1)
Until you introduce fonts to Rails
Introduction to Linux Container / Docker (Part 2)
2. Create Docker image and register Registry
Pass environment variables to docker container
[Docker] Operation up to container creation # 2
[Docker] How to build when the source code is bind-mounted on the container