-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpull_images.sh
More file actions
executable file
·92 lines (78 loc) · 2.84 KB
/
pull_images.sh
File metadata and controls
executable file
·92 lines (78 loc) · 2.84 KB
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#!/bin/bash
# Defaults
MODE="sample"
USERNAME="shuoxin"
# Parse arguments
while [[ $# -gt 0 ]]; do
case $1 in
--all)
MODE="all"
shift
;;
--sample)
MODE="sample"
shift
;;
--username)
USERNAME="$2"
shift 2
;;
-h|--help)
echo "Usage: $0 [--all|--sample] [--username <username>]"
echo " --sample: Pull sample images (default)"
echo " --all: Pull all images"
echo " --username <name>: Docker Hub username (default: shuoxin)"
exit 0
;;
*)
echo "Unknown option: $1"
echo "Usage: $0 [--all|--sample] [--username <username>]"
echo " --sample: Pull sample images (default)"
echo " --all: Pull all images"
echo " --username <name>: Docker Hub username (default: shuoxin)"
exit 1
;;
esac
done
# Determine which file to use
if [ "$MODE" = "all" ]; then
IMAGES_FILE="$(dirname "$0")/dockerhub_images.txt"
echo "Pulling all images from dockerhub_images.txt..."
else
IMAGES_FILE="$(dirname "$0")/sample_images.txt"
echo "Pulling sample images from sample_images.txt..."
fi
echo "Using Docker Hub username: $USERNAME"
# Pull all images, replacing mswebench/ with specified username
# For images that had mswebench/, re-tag them back after pulling
while IFS= read -r original_image || [ -n "$original_image" ]; do
# Skip empty lines
if [ -z "$original_image" ]; then
continue
fi
# Check if image has mswebench/
if [[ "$original_image" == mswebench/* ]]; then
# Replace mswebench/ with USERNAME/
pull_image="${original_image/mswebench\//${USERNAME}/}"
echo "Pulling $pull_image..."
docker pull "$pull_image"
# Re-tag back to original mswebench/ name
echo "Re-tagging $pull_image -> $original_image"
docker tag "$pull_image" "$original_image"
else
# Pull image as-is (e.g., rynge/einsteintoolkit)
echo "Pulling $original_image..."
docker pull "$original_image"
fi
done < "$IMAGES_FILE"
echo "Done!"