logoalt Hacker News

duped06/26/20252 repliesview on HN

A lot of people are replying to the title instead of the article.

> To get your Rust program in a container, the typical approach you might find would be something like:

If you have `cargo build --target x86_64-unknown-linux-musl` in your build process you do not need to do this anywhere in your Dockerfile. You should compile and copy into /sbin or something.

If you really want to build in a docker image I would suggest using `cargo --target-dir=/target ...` and then run with `docker run --mount type-bind,...` and then copy out of the bind mount into /bin or wherever.


Replies

remram06/27/2025

The author dismissed that option saying "I value that docker build can have a clean environment every time", so this is self-inflicted.

edude0306/27/2025

Many docker users develop on arm64-darwin and deploy to x86_64 (g)libc, so I don't think that'll work generally.

show 1 reply