I have a python application image which is over 2.08 GB. I’m trying to optimize the final image size below 500 MB. Application source code size is just below 1 MB. The base image I use is oraclelinux 8 which is 348 MB.
Steps used in Dockerfile
FROM oraclelinux:8
RUN dnf clean all &&
dnf update -y &&
COPY . /application
RUN dnf install python3.11 python-pip3.11
RUN pip3.11 install /application
CMD /app.sh
I tried dnf clean all and rm -rf /var/cache/dnf to clear the dnf cache still the final image is over 1 GB. When I run dnf update it is having only 28MB size of update. Also the requirements.txt contains 4 dependency whose size is below 100 MB. But the final size is over 2GB
I tried dnf clean all and rm -rf /var/cache/dnf to clear the dnf cache still the final image is over 1 GB. When I run dnf update it is having only 28MB size of update. But the final size is above 2 GB. How can I further optimize the size.
Steps used in Dockerfile
FROM oraclelinux:8
RUN dnf clean all &&
dnf update -y &&
COPY . /application
RUN dnf install python3.11 python-pip3.11
RUN pip3.11 install /application
CMD /app.sh
Sam Manickaraj is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.