赞
踩
因为某些原因,docker hub目前访问有些问题,导致docker拉取不了镜像,下面介绍一种解决方法。
image-helper.bash
脚本文件内容如下:
#!/bin/bash
imageDir=~/tmp/images
force=
savei(){
for arg in "$@"
do
img=
name=
if [[ $arg = "-f" ]]; then
force=true
continue
fi
if [[ $arg == *":"* ]]; then
img=$arg
else
img=$arg:latest
fi
name=$(echo $img | sed "s/\//_/g")
name=$(echo $name | sed "s/:/__/")
name=${imageDir}/$name.$(dpkg --print-architecture).tar.gz
echo $arg
if [ -f ${name} ] && [[ $force == "" ]]; then
echo "${img} is saved"
else
docker pull $img && \
docker save $img | gzip > ${name} && \
echo "${img} is saved on ${name}" || \
echo "${img} is failed to save"
fi
echo "-------------------------------"
done
}
synci(){
cd ${imageDir} && sha256sum * > hashes.txt && cd -
rsync -avP ~/tmp/images/ 192.168.3.12:~/Documents/images
}
执行脚本
source ./image-helper.bash
执行批量保存镜像
savei mysql postgres
获取mysql postgres这两个镜像并保存到文件中
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。