How to migrate all docker container images from docker repo at once?
I have a private docker repository where I store 10 container images. I want to pull all the images onto the car. is there a way i can pull all images from repo with one command? some command like
docker pull xx.xx.com/reponame/*
while researching, I found ways to pull out all the tags of a single image; but so far no luck on all images
+7
source to share
6 answers
Run the below shell script to pull ALL DOCKER IMAGES with ALL TAGS from the Docker registry at once,
SHELL SCRIPT:
#/bin/bash
set-x
registry="registry name/ip:port"
repos='curl -u cloudfx:cFx2018Aug http://$registry/v2/_catalog?n=300 | jq '.repositories[]' | tr -d '"''
for repo in $repos; do
docker pull --all-tags $registry/$repo;
done
+2
source to share
Easy.
Install jq to parse JSON, edit the REGISTRY variable and run this script:
#!/bin/sh
REGISTRY="http://registry:5000"
for repo in $(curl -s $REGISTRY/v2/_catalog | jq -r '.repositories[]') ; do
for tag in $(curl -s $REGISTRY/v2/$repo/tags/list | jq -r '.tags[]') ; do
docker pull $REGISTRY/$repo:$tag
done
done
More on Docker Registry API: https://github.com/docker/distribution/blob/master/docs/spec/api.md
+1
source to share
As for the docker : docker pull command documentation , you can use the option
--all-tags
upload all tagged images to storage.
In your case, it would be:
docker pull --all-tags xx.xx.com/reponame
+1
source to share