Skip to content

Commit 845d6b2

Browse files
Check that DinD uses the overlay2 storage driver:
As hook-docker uses the overlay2 storage driver the DinD image must use the overlay2 storage driver too. Signed-off-by: Jacob Weinstock <[email protected]>
1 parent 67a2d6c commit 845d6b2

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

images/hook-embedded/pull-images.sh

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,16 @@ function docker_remove_image() {
2626
docker rmi "${image}" || true
2727
}
2828

29+
function trap_handler() {
30+
local dind_container="$1"
31+
32+
if [[ "${remove_dind_container}" == "true" ]]; then
33+
docker rm -f "${dind_container}" &> /dev/null
34+
else
35+
echo "DinD container NOT removed, please remove it manually"
36+
fi
37+
}
38+
2939
function main() {
3040
local dind_container="$1"
3141
local images_file="$2"
@@ -47,10 +57,11 @@ function main() {
4757
docker_save_image "${first_image}" "${output_dir}"
4858
done < "${images_file}"
4959

60+
export remove_dind_container="true"
5061
# as this function maybe called multiple times, we need to ensure the container is removed
51-
trap "docker rm -f "${dind_container}" &> /dev/null" RETURN
62+
trap "trap_handler ${dind_container}" RETURN
5263
# we're using set -e so the trap on RETURN will not be executed when a command fails
53-
trap "docker rm -f "${dind_container}" &> /dev/null" EXIT
64+
trap "trap_handler ${dind_container}" EXIT
5465

5566
# start DinD container
5667
# In order to avoid the src bind mount directory (./images/) ownership from changing to root
@@ -70,6 +81,16 @@ function main() {
7081
fi
7182
done
7283

84+
# As hook-docker uses the overlay2 storage driver the DinD must use the overlay2 storage driver too.
85+
# make sure the overlay2 storage driver is used by the DinD container.
86+
# The VFS storage driver might get used if /var/lib/docker in the DinD container cannot be used by overlay2.
87+
storage_driver=$(docker exec "${dind_container}" docker info --format '{{.Driver}}')
88+
if [[ "${storage_driver}" != "overlay2" ]]; then
89+
export remove_dind_container="false"
90+
echo "DinD container is not using overlay2 storage driver, storage driver detected: ${storage_driver}"
91+
exit 1
92+
fi
93+
7394
# remove the contents of /var/lib/docker-embedded so that any previous images are removed. Without this it seems to cause boot issues.
7495
docker exec "${dind_container}" sh -c "rm -rf /var/lib/docker-embedded/*"
7596

@@ -97,7 +118,7 @@ function main() {
97118
}
98119

99120
arch="${1-amd64}"
100-
dind_container_name="hookos-dind-${arch}"
121+
dind_container_name="hookos-dind"
101122
images_file="images.txt"
102123
dind_container_image="${2-docker:dind}"
103124
main "${dind_container_name}" "${images_file}" "${arch}" "${dind_container_image}"

0 commit comments

Comments
 (0)