0
votes

I'm adding RPMS to my docker image and installing them during the image build. I have the feeling that I have the RPMS twice in my image. At the place where I added them and at the place where RPM installed them. In total there is about 500 MB RPMS (yes they are big) and the final docker image grows from 700 MB base image to 2.1 GB final image.

Question: How can I avoid ADDing them to the image at all.

First idea I had was putting them into a local yum repository and then use yum to install from the repository. This would remove the ADDing to the docker image.

Is there any other possibility? Why can't I mound a external server volume and install the file from there?

1

1 Answers

2
votes

You have them in /var/cache/dnf.

You may try:

RUN   dnf -y install httpd
RUN   dnf clean all

But you will find that it will not make the image smaller. That is because docker will create the image layer after each RUN section. Therefore you must do:

RUN   dnf -y install httpd && \
      dnf clean all

This will create image layer after both commands and it should be significantly smaller.