I'm currently building containers which contain cross-compilers. As these have to be built during the build phase it would be really useful if I could use tmpfs for this as the build directory will be pointless once the various packages have been installed. Is there any way I can convince docker to mount a tmpfs partition while building?
Asked
Active
Viewed 1,544 times
5
-
Not sure what you mean by build directory being a tmpfs. Docker already configures with its storage driver to handle image spaces under /var/lib/docker/storagedriver. If you mean pointless, getting rid of image layers then you won't be able to do "docker run" the image. Idk if I am understanding you correctly – ealeon Apr 24 '18 at 03:49
-
@ealeon: I want to build a cross-compiler but there is no point keeping the build artefacts around after you've run make install. Otherwise the image will have a bunch of left over crap from the build swelling up the layer. – stsquad Apr 24 '18 at 11:27
-
1@stsquad use multi-stage builds - https://docs.docker.com/develop/develop-images/multistage-build/, so you can first build whatever you need with lots of dependencies, and only extract useful artifacts into second, clean image. – toriningen Aug 05 '18 at 21:12