Skip to content

Commit 4165fe2

Browse files
Update the embed process:
This removes the need to mv the directory of embedded images. This is accomplished by bind mount (rw) the read only images location onto the /var/lib/docker directory in the Hook-docker container. This means that start up doesn't need to wait for the mv command to complete. So startup doesn't incur any delay like it was with the mv. This also means that we can embed a lot more images with having start up issue. In testing, I found that if enough images, compared to the amount of memory available, were embedded then HookOS would not boot up. It would max out on memory. It's possible with enough time that it would have booted but i didnt wait longer than about 30min. Signed-off-by: Jacob Weinstock <[email protected]>
1 parent d481896 commit 4165fe2

File tree

5 files changed

+20
-16
lines changed

5 files changed

+20
-16
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,8 @@ For use cases where having container images already available in Docker is neede
166166

167167
> Note: This is optional and no container images will be embedded by default.
168168
169+
> Note: This will increase the overall size of HookOS. As HookOS is an in memory OS, make sure that the size increase works for the machines you are provisioning.
170+
169171
1. Create a file named `images.txt` in the [images/hook-embedded/](images/hook-embedded/) directory.
170172
1. Populate this `images.txt` file with the list of images to be embedded. See [images/hook-embedded/images.txt.example](images/hook-embedded/images.txt.example) for details on the required file format.
171173
1. Change directories to [images/hook-embedded/](images/hook-embedded/) and run [`pull-images.sh`](images/hook-embedded/pull-images.sh) script when building amd64 images and run [`pull-images.sh arm64`](images/hook-embedded/pull-images.sh) when building arm64 images. Read the comments at the top of the script for more details.

images/hook-docker/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@ 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
1617

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

images/hook-docker/entrypoint.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/sh
2+
3+
set -xeuo pipefail
4+
5+
# This allows us to embed container images into HookOS.
6+
# We assume that any images are stored in /etc/embedded-images.
7+
# The /etc directory in Linuxkit is a read-only filesystem.
8+
# DinD requires that its data directory is writable.
9+
# So we bind mount /etc/embedded-images to /var/lib/docker to make it writable.
10+
mount --bind /etc/embedded-images/ /var/lib/docker
11+
mount -o remount,rw /var/lib/docker
12+
13+
/hook-docker

images/hook-embedded/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
FROM scratch
22
ENTRYPOINT []
33
WORKDIR /
4-
COPY ./images/ /
4+
COPY ./images/ /etc/embedded-images/
55
CMD []

linuxkit-templates/hook.template.yaml

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,9 @@ init:
2323
- "${HOOK_CONTAINER_CONTAINERD_IMAGE}"
2424
- linuxkit/ca-certificates:v1.0.0
2525
- linuxkit/firmware:24402a25359c7bc290f7fc3cd23b6b5f0feb32a5 # "Some" firmware from Linuxkit pkg; see https://github.com/linuxkit/linuxkit/blob/master/pkg/firmware/Dockerfile
26-
27-
volumes:
28-
- name: embedded-images
29-
image: "${HOOK_CONTAINER_EMBEDDED_IMAGE}"
26+
- "${HOOK_CONTAINER_EMBEDDED_IMAGE}"
3027

3128
onboot:
32-
- name: embedded-images
33-
image: alpine
34-
binds:
35-
- /var/run/images:/var/run/images
36-
- embedded-images:/images
37-
command: [ "sh", "-xc", "mv /images/* /var/run/images/" ]
38-
runtime:
39-
mkdir:
40-
- /var/run/images
41-
4229
- name: rngd1
4330
image: linuxkit/rngd:v1.0.0
4431
command: [ "/sbin/rngd", "-1" ]
@@ -196,6 +183,7 @@ services:
196183
- /var/run/docker:/var/run
197184
- /var/run/images:/var/lib/docker
198185
- /var/run/worker:/worker
186+
- /etc/embedded-images/:/etc/embedded-images/
199187
runtime:
200188
mkdir:
201189
- /var/run/images

0 commit comments

Comments
 (0)