Skip to content

Commit b490bac

Browse files
Load images from inside DinD:
This resolves issues with needing to mount the docker.sock and needing sudo. Signed-off-by: Jacob Weinstock <[email protected]>
1 parent 882aa21 commit b490bac

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

images/hook-embedded/pull-images.sh

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,7 @@ function docker_save_image() {
1919
local output_dir="$2"
2020
local output_file="${output_dir}/$(echo "${image}" | tr '/' '-')"
2121

22-
docker save -o "${output_file}" "${image}"
23-
}
24-
25-
function docker_load_image() {
26-
local image_file="$1"
27-
local socket_location="$2"
28-
29-
sudo -E DOCKER_HOST=unix://"${socket_location}" docker load -i "${image_file}"
22+
docker save -o "${output_file}".tar "${image}"
3023
}
3124

3225
function docker_pull_image() {
@@ -73,7 +66,7 @@ function main() {
7366
# will change the permissions of the bind mount directory (images/) to root.
7467
echo -e "Starting DinD container"
7568
echo -e "-----------------------"
76-
docker run -d --privileged --name "${dind_container}" -v ${PWD}/docker:/run -v ${PWD}/images/:/var/lib/docker-embedded/ -d "${dind_container_image}"
69+
docker run -d --privileged --name "${dind_container}" -v "${PWD}/images_tar":/images_tar -v "${PWD}"/images/:/var/lib/docker-embedded/ -d "${dind_container_image}"
7770

7871
# wait until the docker daemon is ready
7972
until docker exec "${dind_container}" docker info &> /dev/null; do
@@ -90,7 +83,8 @@ function main() {
9083

9184
# Load the images
9285
for image_file in "${output_dir}"/*; do
93-
docker_load_image "${image_file}" "${PWD}/docker/docker.sock"
86+
echo -e "Loading image: ${image_file}"
87+
docker exec "${dind_container}" docker load -i "/images_tar/$(basename ${image_file})"
9488
done
9589

9690
# clean up tar files

0 commit comments

Comments
 (0)