forked from longhorn/longhorn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathload-images.sh
executable file
·73 lines (66 loc) · 1.63 KB
/
load-images.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/bin/bash
list="longhorn-images.txt"
POSITIONAL=()
while [[ $# -gt 0 ]]; do
key="$1"
case $key in
-r|--registry)
reg="$2"
shift # past argument
shift # past value
;;
-l|--image-list)
list="$2"
shift # past argument
shift # past value
;;
-i|--images)
images="$2"
shift # past argument
shift # past value
;;
-h|--help)
help="true"
shift
;;
*)
echo "Error! invalid flag: ${key}"
help="true"
break
;;
esac
done
usage () {
echo "USAGE: $0 [--image-list longhorn-images.txt] [--images longhorn-images.tar.gz] --registry my.registry.com:5000"
echo " [-l|--images-list path] text file with list of images. 1 per line."
echo " [-i|--images path] tar.gz generated by docker save. If empty, the script will try to find images in local docker images"
echo " [-r|--registry registry:port] target private registry:port. By default, registry is Docker Hub"
echo " [-h|--help] Usage message"
}
if [[ $help ]]; then
usage
exit 0
fi
if [[ -n $reg ]]; then
reg+="/"
fi
set -e -x
if [[ $images ]]; then
docker load --input ${images}
fi
for i in $(cat ${list}); do
case $i in
*/*/*)
docker tag ${i} ${reg}longhornio/${i#*/*/}
docker push ${reg}longhornio/${i#*/*/}
;;
*/*)
docker tag ${i} ${reg}longhornio/${i#*/}
docker push ${reg}longhornio/${i#*/}
;;
*)
docker tag ${i} ${reg}longhornio/${i}
docker push ${reg}longhornio/${i}
;;
esac
done