-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheasypull-entrypoint.sh
More file actions
54 lines (43 loc) · 1.72 KB
/
easypull-entrypoint.sh
File metadata and controls
54 lines (43 loc) · 1.72 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
#!/bin/sh
set -e
#
# Function to ensure a variable is set
# parameter 1: variable value
# parameter 2: variable name
# parameter 3: example value
#
function checkVar() {
if [ -z ${1} ]; then
echo "ENVIRONMENT VAR [$2] not set, set it on the run command with:"
echo "-e \"$2=$3\"."
echo "Exiting.";
exit 1;
else
echo "$2 = '${1}'";
fi
}
###################################################################
# Runtime validation #
###################################################################
checkVar "${PULL_TAG}" "PULL_TAG" "busybox:latest"
checkVar "${OUTPUT_FILE}" "OUTPUT_FILE" "/tmp/images/busybox.tar"
###################################################################
# Runtime replacement of configuration prior to launching dockerd #
###################################################################
# Replace Insecure Registries - no certificate verification
sed -i "s/INSECURE_REGS/${INSECURE_REGS}/g" /etc/docker/daemon.json
###################################################################
# Run dockerd #
###################################################################
dockerd &
while ! ps aux | grep -v "grep" | grep -q "dockerd" ; do
echo "***********************WAITING FOR DOCKER TO START***********************";
sleep 2;
done
echo "***********************DOCKER STARTED***********************"
###################################################################
# Pull and save the image #
###################################################################
docker pull "${PULL_TAG}"
echo "Saving file to: ${OUTPUT_FILE}"
docker save -o "${OUTPUT_FILE}" "${PULL_TAG}"