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


Try this (it will update images that have no direct pluggable containers)

docker images | awk '(NR>1) && ($2!~/none/) {print $1":"$2}' | xargs -L1 docker pull

      



Try this line first to see which images will be covered:

docker images | awk '(NR>1) && ($2!~/none/) {print $1":"$2}'

      

+3


source


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


Couldn't "hack" this with docker-compose

.

# docker-compose.yml
version: '3.1'
services:
  a:
    image: a-image
  b:
    image: b-image
  c:
    image: c-image
# .....

      

docker-compose pull --parallel

+1


source


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


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


Not sure what type of command is one command, one line?

for repo in repo1 repo2 repo3; do docker pull xx.xx.com/$repo; done

      

0


source







All Articles