Installation procedures can produce a lot of logs and other cached files. This script attemts to clean up these files to make docker images a lot smaller.
ENV CLEANIMAGE_VERSION 2.0
ENV CLEANIMAGE_URL https://raw.githubusercontent.com/LolHens/docker-cleanimage/$CLEANIMAGE_VERSION/cleanimage
ADD ["$CLEANIMAGE_URL", "/usr/local/bin/"]
RUN chmod +x "/usr/local/bin/cleanimage"
RUN apt-get install -y \
python3 \
&& cleanimage
- apt
- yum
- apk
- pip
- apt-get -y --purge autoremove
- apt-get -y clean
- yum clean all
- /tmp/*
- /var/cache/apk/*
- /var/tmp/*
- /var/lib/apt/lists/*
- /var/log/alternatives.log
- /var/log/apt/
- /var/log/bootstrap.log
- /var/log/btmp
- /var/log/dpkg.log
- /var/log/faillog
- /var/log/fsck/
- /var/log/lastlog
- /var/log/wtmp
- ~/.cache/pip
- Files in /var/cache/