Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Yes, you can use Nix to get extremely small Docker images. I have personally used it to that effect, but it's not a magic bullet. In this specific case, it gives pretty bad results even. I have written the simplest possible Nix derivation for ugit and the resulting Docker image is 158MB gzipped. I haven't explored fully why that is, but that's much worse than even the first effort from the OP.


I got it down to about 33M, gzipped with musl (completely untested, of course)[0].

Most of it seems to be from git:

$ nix path-info --closure-size --human-readable nixpkgs#legacyPackages.x86_64-linux.gitMinimal

/nix/store/f7b2yl226nbikiv6sbdhmaxg2452c8h5-git-minimal-2.42.0 112.9M

$ nix path-info --closure-size --human-readable nixpkgs#legacyPackages.x86_64-linux.pkgsMusl.gitMinimal

/nix/store/25807yw3143a94dpr3a3rffya7vg5r24-git-minimal-2.42.0 73.5M

Apparently "gitMinimal" is not all that minimal:

$ ls /nix/store/25807yw3143a94dpr3a3rffya7vg5r24-git-minimal-2.42.0/libexec/git-core/ | wc -l

172

[0]: https://gist.github.com/jbboehr/3a5d0dd52a0c1139ce88b76ab82a...




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: