Hacker News (curated)new | past | comments | ask | show | jobs| show hidden

Woah, TIL! My Alpine Linux world view has just been shattered. Static linking was frankly *the* selling point of Alpine Linux for me and it turns out I was just plain wrong.


Alpine selling point was that it's small, which was selling people only for people that either don't understand docker layers or can't make Dockerfile correctly.

Alpine’s connection to static linking is mainly that it provides a convenient musl build environment. A fully static binary can run in `FROM scratch`.


> A fully static binary can run in `FROM scratch`.

Not just `FROM scratch` but also in other contexts. For example:

I wrote my own password manager which lives on a USB drive. Since I compiled a static binary, I can execute it on any Linux machine.

Running static binaries in FreeBSD's Linuxulator is easier. The Linuxulator is a separate set of syscalls that get used when you attempt to run a Linux binary, so a static binary will "just work" for the most part (unless the program needs special filesystems like /proc or /sys). A dynamically linked binary means I need to make sure I have any necessary Linux libraries in the proper location and the Linuxulator's `ld` working properly. Updates to these libraries can then make something that used to work, suddenly stop working. Certainly not an insurmountable task, but there's so many fewer places where things can break when you're just running a static binary.


Well, `FROM scratch` implies that if there is something that works with linux syscalls (i.e. Linuxulator) then it generally runs. Unless, like you said, it needs special filesystems.

> which was selling people only for people that either don't understand docker layers or can't make Dockerfile correctly.

I don't think that's fair. Alpine-derived images are generally smaller, all things held equal. Of course if you do everything else right then it will matter less, but a proper multistage Dockerfile should still be smaller than the same thing built out of another distro (most of the time).




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