简体   繁体   中英

Mirror Docker container image to Google Container Registry using least dependencies/permissions

I need to perform the following from a python program:

docker pull foo/bar:tag
docker tag foo/bar:tag gcr.io/project_id/mirror/foo/bar:tag
gcloud auth configure-docker --quiet
docker push gcr.io/project_id/mirror/foo/bar:tag

I want to accomplish this with the minimal possible footprint - no root, no privileged Docker installation, etc. The Google Cloud SDK is installed.

How to programmatically mirror the image with minimal app footprint?

Google cloud build API can be used to perform all your required steps in one command Or use Trigger.

  1. gcloud builds submit --tag gcr.io/$DEVSHELL_PROJECT_ID/$UMAGE_NAME:v0.1.

Above command, you can call using Python cloud Build API https://googleapis.dev/python/cloudbuild/latest/gapic/v1/api.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM