I have list of .tar docker image files , I have tried loading docker images using below commands
docker load -i *.tar
docker load -i alldockerimages.tar
where alldockerimages.tar
contains all individual tar files .
Let me know how we can load multiple tar files.
答案 0 :(得分:3)
First I attempted to use the glob expression approach you first described:
# download some images to play with
docker pull alpine
docker pull nginx:alpine
# stream the images to disk as tarballs
docker save alpine > alpine.tar
docker save nginx:alpine > nginx.tar
# delete the images so we can attempt to load them from scratch
docker rmi alpine nginx:alpine
# issue the load command to try and load all images at once
cat *.tar | docker load
Unfortunately this only resulted in alpine.tar
being loaded. It was my (presumably faulty) understanding that the glob expression would be expanded and ultimately cause the docker load
command to be run for every file into which the glob expression expanded.
Therefore, one has to use a shell for
loop to load all tarballs sequentially:
for f in *.tar; do
cat $f | docker load
done
答案 1 :(得分:2)
使用xargs:
ls -1 *.tar | xargs --no-run-if-empty -L 1 docker load
答案 2 :(得分:0)
使用save-load-docker-images.sh中描述的脚本来保存或加载图像。对于您而言,应该是
./save-load-docker-images.sh load -d <directory-location>