I reduced the size of my Docker image by 40% – Dockerizing shell scripts

This page summarizes the projects mentioned and recommended in the original post on news.ycombinator.com

Our great sponsors
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • WorkOS - The modern identity platform for B2B SaaS
  • SaaSHub - Software Alternatives and Reviews
  • dive

    A tool for exploring each layer in a docker image

  • Dive is a great tool for debugging this. I like image reduction work just because it gives me a chance to play with Dive: https://github.com/wagoodman/dive

    One easy low hanging fruit I see a LOT for ballooning image sizes is people including the kitchen sink SDK/CLI for their cloud provider (like AWS or GCP), when they really only need 1/100 of that. The full versions of both of these tools are several hundred mb each

  • bubblewrap

    Low-level unprivileged sandboxing tool used by Flatpak and similar projects

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

    InfluxDB logo
  • exodus

    Painless relocation of Linux binaries–and all of their dependencies–without containers.

  • COPY --from=ugit-ops /lib/ld-musl-* /lib/

    No, what I'm saying is you're blanket copying fully different versions of common library files into the operating system lib folder as shown above, possibly breaking OS lib symlinks in the process for _current_ versions used in Alpine OS if they exist now or in the future, potentially destroying OS lib dependencies, and also overwriting the ones possibly included in the future by Alpine OS itself to get your statically copied versions of the various CLI tools to work.

    That is _insanely_ shortsighted. There's a safe way to do that and then there is the way you did it. If you want to learn to do it right, look at how Exodus does it so that they don't destroy OS library dependency files in the process of making a binary able to be moved from one OS to another.

    Exodus: https://github.com/intoli/exodus

  • hadolint

    Dockerfile linter, validate inline bash, written in Haskell

  • This is neat :)

    I love going and making containers smaller and faster to build.

    I don't know if it's useful for alpine, but adding a --mount=type=cache argument to the RUN command that `apk add`s might shave a few seconds off rebuilds. Probably not worth it, in your case, unless you're invalidating the cached layer often (adding or removing deps, intentionally building without layer caching to ensure you have the latest packages).

    Hadolint is another tool worth checking out if you like spending time messing with Dockerfiles: https://github.com/hadolint/hadolint

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts