---
title: "Cross-compiling static Rust binaries in Docker for Raspberry Pi"
url: https://daily.dev/posts/cross-compiling-static-rust-binaries-in-docker-for-raspberry-pi-r2khkezoj
source_url: https://jakewharton.com/cross-compiling-static-rust-binaries-in-docker-for-raspberry-pi
type: article
source: "Jake Wharton"
published: 2026-07-05T07:13:18.622Z
updated: 2026-07-05T07:13:50.369Z
tags: ["docker", "rust", "raspberry-pi"]
reading_time: 6
upvotes: 0
comments: 0
language: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Cross-compiling static Rust binaries in Docker for Raspberry Pi

**[Jake Wharton](https://daily.dev/sources/jakewharton)** · 6 min read · 0 upvotes · 0 comments

## Summary

A step-by-step walkthrough for cross-compiling static Rust binaries targeting Raspberry Pi (ARMv7 and ARMv6) inside Docker using musl for static linking. Covers setting up Rust targets with rustup, configuring the linker in .cargo/config, optimizing binary size via Cargo.toml release profile settings (opt-level z, LTO, single codegen unit), and building multi-architecture Docker images using Docker buildx with BUILDPLATFORM and TARGETPLATFORM arguments to dynamically select the correct Rust compilation target per architecture.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://jakewharton.com/cross-compiling-static-rust-binaries-in-docker-for-raspberry-pi>

## Similar posts on daily.dev

- [Hello Rust’y Pico — Part 1: Setting Up Embedded Rust](https://daily.dev/posts/hello-rust-y-pico-part-1-setting-up-embedded-rust-c1valaaeu) · Medium · 2 upvotes · 1 comments

---

Tags: [#docker](https://daily.dev/tags/docker), [#rust](https://daily.dev/tags/rust), [#raspberry-pi](https://daily.dev/tags/raspberry-pi)

[View this post on daily.dev](https://daily.dev/posts/cross-compiling-static-rust-binaries-in-docker-for-raspberry-pi-r2khkezoj)
