docker 批量导出脚本
用for 循环实现
docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
gcr.io/google_containers/k8s-dns-dnsmasq-nanny-amd64 1.14.4 21fe417043dd 2 months ago 41.4MB
gcr.io/google_containers/kube-apiserver-amd64 v1.6.0 489cabacd734 9 months ago 150MB
[root@hd11 ~]#
docker images|sed -n '3,$p'|awk -F '[/]' '{print $3}'|awk '{print $1"_"$2".tar"}'
k8s-dns-dnsmasq-nanny-amd64_1.14.4.tar
kube-apiserver-amd64_v1.6.0.tar
docker images|sed -n '3,$p'|awk '{print $1":"$2}'
gcr.io/google_containers/k8s-dns-dnsmasq-nanny-amd64:1.14.4
gcr.io/google_containers/kube-apiserver-amd64:v1.6.0
#!/bin/bash tar = `docker images|sed -n '3,$p'|awk -F '[/]' '{print $3}'|awk '{print $1"_"$2".tar"}'` images = `docker images|sed -n '3,$p'|awk '{print $1":"$2}'` for i in $tar
do for j in $images do docker save -o $i $j done done