问题
I have a private docker repo in which i have 10 container images stored. I want to pull all images to a machine. is there a way i can pull all images from a repo with a single command? some command like
docker pull xx.xx.com/reponame/*
while researching I found ways to pull all tags of a single image; but no luck so far on all images
回答1:
Try this (it will update images that does not have running containers directly attached to them)
docker images | awk '(NR>1) && ($2!~/none/) {print $1":"$2}' | xargs -L1 docker pull
Try out this line out first to see what images will be covered:
docker images | awk '(NR>1) && ($2!~/none/) {print $1":"$2}'
回答2:
Regarding the docker documentation of the command: docker pull, you could use the option
--all-tags
to download all tagged images in the repository.
In your case, it would be :
docker pull --all-tags xx.xx.com/reponame
回答3:
Could '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
回答4:
Run below shell script to pull ALL DOCKER IMAGES with ALL TAGS from a 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
回答5:
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
For details on the Docker Registry API: https://github.com/docker/distribution/blob/master/docs/spec/api.md
回答6:
Not sure what type of command is a single command, one-liner?
for repo in repo1 repo2 repo3; do docker pull xx.xx.com/$repo; done
来源:https://stackoverflow.com/questions/44339700/how-to-pull-all-docker-container-images-from-docker-repo-at-once