containers / build

another build tool for container images (archived, see https://github.com/rkt/rkt/issues/4024)
Apache License 2.0
342 stars 80 forks source link

feature request: bind mounts from the host during build #296

Open tummychow opened 7 years ago

tummychow commented 7 years ago

I'd like to be able to bind mount host directories into the ACI before performing acbuild run commands. If I need large files inside the ACI at build time, but not at runtime, I can put those files on the host, then bind mount them into the ACI for acbuild run.

Concrete example: I have a large binary installer (eg for a video game), in the neighborhood of 60GB. If I want to build an ACI for this program, I need to expose the installer to acbuild somehow. But I don't want to acbuild copy the installer into the build context, because 1) that's excruciatingly slow, 2) requires a ton of temporary space on my disk, and 3) I would have to remove it right afterwards to avoid bloating the container. It would be much more convenient to have the binary in a directory on the host, and bind mount that directory into the container for the duration of the single acbuild run command that actually executes the binary.

Another concrete example: I'm running a build process that invokes pacman -Syu, which downloads a bunch of tarballs and puts them in a cache directory. If I have bind mounts, I can bind mount the host's pacman cache into the container before running pacman, and it'll reuse any cached packages that my host already has. This would save bandwidth and download time if I'm rebuilding the container over and over again in an edit-rebuild-run cycle.

Bind mounts look like the obvious solution to me, but I'm open to any other approaches. If it means avoiding a 60GB copy, I'm totally fine with a nasty hack that I can use without waiting for a new feature.

cgonyeo commented 7 years ago

This would definitely be a useful feature. Unfortunately I don't have much time for acbuild at the moment, but I'll leave this issue open for when I can find time in the future.

You're obviously also welcome to contribute it, if you have the time.

For a short term workaround that has no guarantees of being compatible with future releases, you can also bind mount directories into the in-progress image being built at .acbuild/current/rootfs (for appc mode at least).