Code Monkey home page Code Monkey logo

docker-cleanimage's Introduction

docker-cleanimage

A tool for cleaning up temp and cache directories to make docker images smaller

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.

Usage in Dockerfile

Download and install

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"

OR

RUN wget https://raw.githubusercontent.com/mrsrvman/docker-cleanimage/master/cleanimage -O /usr/local/bin//cleanimage \
    && chmod +x /usr/local/bin/cleanimage

OR

FROM debian:buster-slim AS cleaner
RUN apt-get update \
    && apt-get install --assume-yes --no-install-recommends --no-install-suggests  curl ca-certificates \
    && curl https://raw.githubusercontent.com/mrsrvman/docker-cleanimage/master/cleanimage -o /usr/local/bin//cleanimage \
    && chmod +x /usr/local/bin/cleanimage
.......
COPY --from=cleaner /usr/local/bin/cleanimage /usr/local/bin/cleanimage

OR

FROM mrsrvman/docker-cleanimage:latest AS cleaner
COPY --from=cleaner /usr/local/bin/cleanimage /usr/local/bin/cleanimage

Execute after each layer where necessary

RUN apt-get install -y \
      python3 \
 && cleanimage

Supported Applications

  • apt
  • yum
  • apk
  • pip

Commands

  • apt-get -y --purge autoremove
  • apt-get -y clean
  • yum clean all

Directories

  • /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/

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.