Skip to content

Commit 72fde59

Browse files
Change the way the images are presented to hook-docker:
Instead of having hook-docker know about mounting the embedded images, the images get mounted with the right permissions and made available to hook-docker at the "usual" location. This decouples this embedding process from hook-docker. This should allow the two to only be coupled by the mount point of /var/run/images. Signed-off-by: Jacob Weinstock <[email protected]>
1 parent 4165fe2 commit 72fde59

File tree

6 files changed

+25
-16
lines changed

6 files changed

+25
-16
lines changed

images/hook-docker/Dockerfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,5 @@ RUN strip /usr/local/bin/docker /usr/local/bin/dockerd /usr/local/bin/docker-pro
1313
# Purge binutils package after stripping
1414
RUN apk del binutils
1515
COPY --from=dev /hook-docker .
16-
COPY entrypoint.sh /entrypoint.sh
1716

18-
ENTRYPOINT ["/entrypoint.sh"]
17+
ENTRYPOINT ["/hook-docker"]

images/hook-docker/entrypoint.sh

Lines changed: 0 additions & 13 deletions
This file was deleted.

images/hook-embedded/.dockerignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
*
2+
!images/
3+
!docker-mount.sh

images/hook-embedded/Dockerfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,8 @@ FROM scratch
22
ENTRYPOINT []
33
WORKDIR /
44
COPY ./images/ /etc/embedded-images/
5+
# the name 001 is important as that is the order in which the scripts are executed
6+
# we need this mounting to happen before the other init.d scripts run so that
7+
# the mount points are available to them.
8+
COPY ./images-mount.sh /etc/init.d/001-images-mount.sh
59
CMD []

images/hook-embedded/images-mount.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/sh
2+
3+
exec 3>&1 4>&2
4+
trap 'exec 2>&4 1>&3' 0 1 2 3
5+
exec 1>/var/log/embedded-images.log 2>&1
6+
7+
set -xeuo pipefail
8+
9+
# We can't have a Linuxkit "init" container that dumps its file contents to /var and be writable
10+
# because the init process overwrites it and the contents are lost.
11+
# Instead, we have the init container, with all the Docker images, dump its contents to /etc/embedded-images.
12+
# Then we bind mount /etc/embedded-images to /run/images (/var/run is symlinked to /run) and make sure it's
13+
# read/write. This allows the DinD container to bind mount /var/run/images to /var/lib/docker and the Docker
14+
# images are available right away and /var/lib/docker is writable.
15+
mkdir -p /run/images
16+
mount -o bind,rw /etc/embedded-images/ /run/images
17+
mount -o remount,rw /run/images

linuxkit-templates/hook.template.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,6 @@ services:
183183
- /var/run/docker:/var/run
184184
- /var/run/images:/var/lib/docker
185185
- /var/run/worker:/worker
186-
- /etc/embedded-images/:/etc/embedded-images/
187186
runtime:
188187
mkdir:
189188
- /var/run/images

0 commit comments

Comments
 (0)