Skip to content

Conversation

@Xerxes-2
Copy link
Contributor

distroless provides an excellent base image to run Rust programs. For Rust programs linked with musl, use distroless/static which weights ~2MB. For Rust programs linked with glibc, use distroless/cc which is ~20MB

`distroless` provides an excellent base image to run Rust programs.
For Rust programs linked with musl, use `distroless/static` which weights ~2MB.
For Rust programs linked with glibc, use `distroless/cc` which is ~20MB
@johnthagen
Copy link
Owner

@jirutka Curious why the downvote.

@jirutka
Copy link

jirutka commented Aug 15, 2025

Because this project is about “How to minimize Rust binary size”, not how to containerize (or distribute in more general sense) Rust programs. So IMHO this is out of scope of this project.

Moreover, if you want a self-contained program, you can just build a static binary with musl; there’s no reason to wrap it in a container image, unless you have an environment that knows only containers. And again, this is a completely different topic.

@johnthagen
Copy link
Owner

Thank you for your sharing your thoughts!

@jirutka
Copy link

jirutka commented Aug 15, 2025

You’re welcome! :)

@Xerxes-2
Copy link
Contributor Author

Xerxes-2 commented Aug 15, 2025

Because this project is about “How to minimize Rust binary size”, not how to containerize (or distribute in more general sense) Rust programs. So IMHO this is out of scope of this project.

Moreover, if you want a self-contained program, you can just build a static binary with musl; there’s no reason to wrap it in a container image, unless you have an environment that knows only containers. And again, this is a completely different topic.

  1. There's already a Containers section in README.md, so I think this PR is not off topic.
  2. I hate container. However there are platforms that only accept container. At lease distroless provides everything a static linked binary need (CA Certs, TZ, etc.) with minimal size

@johnthagen johnthagen merged commit b0bc6dc into johnthagen:main Aug 15, 2025
16 checks passed
@johnthagen
Copy link
Owner

@Xerxes-2 Thanks for your contribution.

@jirutka
Copy link

jirutka commented Aug 15, 2025

  1. There's already a Containers section in README.md, so I think this PR is not off topic.

I see, I overlooked this section. In that case, this PR is indeed a good addition.

@burdges
Copy link

burdges commented Aug 15, 2025

Ya know, if someone really hates containers enough, then some min-sized-containers repo could be a nice trolling opportunity, maybe reinvent dynamic linking behind the scenes. ;)

@Xerxes-2 Xerxes-2 deleted the add-distroless branch August 16, 2025 04:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants