When you have a complicated RUN apt-get install section that you reuse over multiple docker images, what is the best way to reuse it?
The options that I think we have are
- copy-paste the
RUNcommand n times across your Dockerfiles (this is what I do today) - make a docker image and use it as a build step +
COPY --from=builder...(this is what I wan't, but I don't konw how to do it).
I am thinking of something like this:
- Dockerfile with reusable apt install command, tagged as
my-builder-img:
FROM debian:buster
RUN ... apt-get install ...
- Dockerfile that reuses that complicated install:
FROM my-builder-img as builder
#nothing here
FROM debian:buster
COPY --from=builder /usr/bin:/usr/bin # (...???)
TL;DR how to reuse apt-get install from a previus image onto a new image.