3 ms·
Why not run your existing predictable script in a single RUN command? What need to be converted? The mistake many do is seeing dockerfiles as a 1:1 mapping of
by Too 5y ago
Why not run your existing predictable script in a single RUN command? What need to be converted?
The mistake many do is seeing dockerfiles as a 1:1 mapping of a shell script with RUN prefixed on every line. It’s not, you should only split a run if you have a good reason to add a new COPY in between for layer caching reasons or switching user.
With the --bind options from buildkit you can ensure the apt cache does not get layered and you can mount any big temporary files needed from host instead of copying them first.
- rmetzler 5y agoAlso each RUN, COPY, ADD, etc. creates a new layer in the image so you should put commands which are related in the same command. The example in the blog post violates this principle, which is the main reason for the unexpected size.