4 ms·
It should be possible to split into multiple layers as long as each file is wholly within in its layer. This is the exact opposite of the work recommended combi
by password4321 2y ago
It should be possible to split into multiple layers as long as each file is wholly within in its layer. This is the exact opposite of the work recommended combining commands to keep everything in one layer which I think is done ultimately for runtime performance reasons.
- ramses0 2y agoI've dug fairly deep into docker layering, it would be wonderful if there was a sort of `LAYER ...` barrier instead of implicitly via `RUN ...` lines. Theoretically there's nothing stopping you from building the docker image and "re-layering it", as they're "just" bundles of tar files at the end of the day. eg: `RUN ... ; LAYER /usr ; LAYER /var ; LAYER /etc ; LAYER [discard|remainder]`
- yjftsjthsd-h 2y agoI've wished for a long time that Dockerfiles had an explicit way to define layers ripped off from (postgre)sql: BEGIN RUN foo RUN bar COMMIT
- mdaniel 2y agoAt the very real risk of talking out of my ass, the new versioned Dockerfile mechanism on top of builtkit should enable you to do that: https://github.com/moby/buildkit/blob/v0.15.0/frontend/dockerfile/docs/reference.md#syntax https://github.com/moby/buildkit/blob/v0.15.0/frontend/docke... In true "when all you have is a hammer" fashion, as very best I can tell that syntax= directive is pointing to a separate docker image whose job it is to read the file and translate it into builtkit api calls, e.g. https://github.com/moby/buildkit/blob/v0.15.0/frontend/dockerfile/builder/build.go#L36 https://github.com/moby/buildkit/blob/v0.15.0/frontend/docke... But, again for clarity: I've never tried such a stunt, that's just the impression I get from having done mortal kombat with builtkit's other silly parts
- skrause 2y agoRUN <<EOF foo bar EOF https://www.docker.com/blog/introduction-to-heredocs-in-dockerfiles/ https://www.docker.com/blog/introduction-to-heredocs-in-dock...
- yjftsjthsd-h 2y agoThanks, that helps a lot and I didn't know about it:) It's a touch less powerful than full transactions (because AFAICT you can't say merge a COPY and RUN together) but it's a big improvement.