How to make Docker images even smaller

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

    Nix Packages collection & NixOS

  • There is an example of doing this in the docker-tools examples!

    https://github.com/NixOS/nixpkgs/blob/master/pkgs/build-supp...

  • nix

    Nix, the purely functional package manager

  • Nixos website has very nice example of minimal docker images: https://nixos.org/#asciinema-demo-example_4

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

    🥑 Language focused docker images, minus the operating system.

  • If you decouple you build from your packaging you can also use from-scratch containers. You can also use distroless' static image [0] to get a posix-y environment with as little space as possible. Total image size of the static image is ~2.4mb and it comes with a `nonroot` user configured to lock down your perms and packages like ca-certs that are often forgotten.

    You can make use of this with multistage builds or with build systems like Bazel and Please.build.

    [0] - https://github.com/GoogleContainerTools/distroless/blob/main...

  • lima

    Linux virtual machines, with a focus on running containers

  • > not sure if k8s can run OCI, or if I can push OCI to a docker registry (artifactory)

    I push OCI images to AWS ECR, so it would probably work.

    > I'm on mac/arm but the images need to run on linux/amd64

    I've never used the cross-compilation support in Nixpkgs. My work machine runs macOS (x86_64), so I have a Linux VM as a remote builder. I happen to use LimaVM ( https://github.com/lima-vm/lima ), but anything would work (Qemu, VirtualBox, the VM bundled with Docker Desktop, etc.).

    PS: Since containers only work on Linux, and I'm often working on macOS, I use the following assertion to check that I'm not accidentally including Mac builds in a layer:

        assert all (d: ((d.type or null) == "derivation") -> (d.system == "x86_64-linux")) drvs;

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