4 ms·
I would like to mention one pet peeve of mine wrt docker... cramming everything into one RUN line to save space in a layer. I really wish instead of: RUN f
by m463 3y ago
I would like to mention one pet peeve of mine wrt docker...
cramming everything into one RUN line to save space in a layer.
I really wish instead of:
RUN foo && \
bar && \
bletch
You could do:
LAYER
RUN foo
RUN bar
RUN bletch
LAYER
or something similar.
maybe even during development you could do:
docker build --ignore-layer .
then at the end:
docker build .
- viraptor 3y agoCramming things into one layer can save gigabytes in size. Even if it saves a 100MB, it adds up between multiple CI runs and in deployment latencies. Docker should address it one day, but until then, we just have to do it in real world scenarios.
- a_t48 3y agoParent comment agrees with you, is just asking for more ergonomic syntax
- viraptor 3y agoI get it, just providing more context. Should've phrased it nicer.
- yjftsjthsd-h 3y agoAn alternative solution... for some definition of the term... is to write a "naive" Dockerfile like RUN foo RUN bar RUN baz and then just build it with something like... I think kaniko did this last I looked?... that smashes the whole thing into a single layer. Obviously that has other tradeoffs (no reuse of layers) but depending on your usecase it can be a good trade to make (why yes, I did cut my teeth in an environment where very few images shared a base layer, why do you ask?).
- sre2 3y agoHeredocs (described in the docs[1] under "shell form") was introduced 3 years ago[1]. The flag '--squash' has been in podman for quite a while[2]. It might be time for you to upgrade your tooling. [0]: https://docs.docker.com/reference/dockerfile/#shell-form https://docs.docker.com/reference/dockerfile/#shell-form [1]: https://www.docker.com/blog/introduction-to-heredocs-in-dockerfiles/ https://www.docker.com/blog/introduction-to-heredocs-in-dock... [2]: https://docs.podman.io/en/latest/markdown/podman-build.1.html#squash https://docs.podman.io/en/latest/markdown/podman-build.1.htm...