RustTraining Documentation

Beginner, advanced, expert level Rust training material

14,945 stars Rust Rust 1 file Β· ~2,253 tokens
RAW Doc

Docker & Self-Hosted Deployment Verified OCI

Deploy RustTraining on any server, homelab, or cloud container platform.

1-Click Terminal Command
bash (docker run)
docker run -d --name rusttraining -p 3000:3000 --restart always rust-training:local
Configured Services & Ports
βš™οΈ books
image: rust-training:local
πŸ”Œ Ports: ${PORT:-3000}:8080
docker-compose.yml
yaml (docker-compose.yml)
name: rust-training

services:
  books:
    build:
      # Context is the repo root: the build needs the book sources and the
      # xtask crate, which live above this file.
      context: ..
      dockerfile: docker/Dockerfile
    image: rust-training:local
    container_name: rust-training-books

    # Host port is configurable; the container always listens on 8080 because
    # nginx-unprivileged runs as a non-root user.
    ports:
      - "${PORT:-3000}:8080"

    restart: unless-stopped

    security_opt:
      - no-new-privileges:true

    healthcheck:
      test: ["CMD", "wget", "-q", "-O", "/dev/null", "http://127.0.0.1:8080/"]
      interval: 30s
      timeout: 5s
      start_period: 5s
      retries: 3

Technical Documentation: microsoft/RustTraining

ℹ️ Provenance: Multi-Tier Ingestion Β· CodeWiki Reference

Overview (`README.md`)

License This project is dual-licensed under the MIT License and Creative Commons Attribution 4.0 International (CC-BY-4.0).

Trademarks This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow Microsoft's Trademark & Brand Guidelines. Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-party's policies.

Rust Training Books

Seven training courses covering Rust from different programming backgrounds, plus deep-dives on async, advanced patterns, and engineering practices.

This material combines original content with ideas and examples inspired by some of the best resources in the Rust ecosystem. The goal is to present an in-depth, technically accurate curriculum that weaves together knowledge scattered across books, blogs, conference talks, and video series into a cohesive, pedagogically structured experience.

Disclaimer: These books are training material, not an authoritative reference. While we strive for accuracy, always verify critical details against the official Rust documentation and the Rust Reference.

Inspirations & Acknowledgments

  • The Rust Programming Language β€” the foundation everything builds on
  • Jon Gjengset β€” deep-dive streams on advanced Rust internals, Crust of Rust series
  • withoutboats β€” async design, Pin, and the futures model
  • fasterthanlime (Amos) β€” systems programming from first principles, engaging long-form explorations
  • Mara Bos β€” Rust Atomics and Locks, concurrency primitives
  • Aleksey Kladov (matklad) β€” Rust analyzer insights, API design, error handling patterns
  • Niko Matsakis β€” language design, borrow checker internals, Polonius
  • Rust by Example and Rustonomicon β€” practical patterns and unsafe deep-dives
  • This Week in Rust β€” community discoveries that shaped many examples
  • Binary Musings - Tag(Rust) β€” Deep dive into Rust internals
  • …and many others in the Rust community at large whose blog posts, conference talks, RFCs, and forum discussions have informed this material β€” too numerous to list individually, but deeply appreciated

πŸ“– Start Reading

Pick the book that matches your background. Books are grouped by complexity so you can chart a learning path:

Level Description
🟒 Bridge Learn Rust coming from another language β€” start here
πŸ”΅ Deep Dive Focused exploration of a major Rust subsystem
🟑 Advanced Patterns and techniques for experienced Rustaceans
🟣 Expert Cutting-edge type-level and correctness techniques
🟀 Practices Engineering, tooling, and production readiness
Book Level Who it's for
Rust for C/C++ Programmers 🟒 Bridge Move semantics, RAII, FFI, embedded, no_std
Rust for C# Programmers 🟒 Bridge Swift / C# / Java β†’ ownership & type system
Rust for Python Programmers 🟒 Bridge Dynamic β†’ static typing, GIL-free concurrency
Async Rust πŸ”΅ Deep Dive Tokio, streams, cancellation safety
Rust Patterns 🟑 Advanced Pin, allocators, lock-free structures, unsafe
Type-Driven Correctness 🟣 Expert Type-state, phantom types, capability tokens
Rust Engineering Practices 🟀 Practices Build scripts, cross-compilation, CI/CD, Miri

Each book has 15–16 chapters with Mermaid diagrams, editable Rust playgrounds, exercises, and full-text search.

Tip: Browse the rendered books with sidebar navigation and search at the GitHub Pages site.

Local preview: For offline reading or while contributing (install Rust first):

text
git clone https://github.com/microsoft/RustTraining.git
cd RustTraining
cargo install mdbook mdbook-mermaid
cargo xtask serve    # http://localhost:3000

πŸ”§ For Maintainers

Building, serving, and editing the books locally

Prerequisites

Install Rust via rustup if you haven't already, then:

bash
cargo install [email protected] [email protected]

Clone the repo

bash
git clone https://github.com/microsoft/RustTraining.git
cd RustTraining

Build & serve

bash
cargo xtask build               # Build all books into site/ (local preview)
cargo xtask serve               # Build and serve at http://localhost:3000
cargo xtask deploy              # Build all books into docs/ (for GitHub Pages)
cargo xtask clean               # Remove site/ and docs/

To build or serve a single book:

bash
cd c-cpp-book && mdbook serve --open    # http://localhost:3000

Deployment

The site auto-deploys to GitHub Pages on push to main via .github/workflows/pages.yml. No manual steps needed.


Overview (`docker/README.md`)

Containerized deployment

Optional, opt-in way to self-host the book collection without GitHub Pages β€”
useful behind a firewall or on an internal network.

This is not the local development path. For writing and previewing, use
cargo xtask serve, which rebuilds and serves at http://localhost:3000 with
no container involved.

Usage

From the repository root:

bash
docker compose -f docker/compose.yaml up --build

Then open http://localhost:3000. Override the host port with PORT:

bash
PORT=8080 docker compose -f docker/compose.yaml up --build

Without Compose:

bash
docker build -f docker/Dockerfile -t rust-training .
docker run --rm -p 3000:8080 rust-training

Note the build context is the repository root in both cases β€” the build needs
the book sources and the xtask crate.

How it works

Two stages:

  1. builder (rust:1-slim-bookworm) installs mdbook and mdbook-mermaid,
    then runs cargo xtask build, which builds all seven books into site/
    along with the generated landing page.
  2. runtime (nginxinc/nginx-unprivileged:alpine) serves site/ on port
    1. No Rust toolchain, no mdbook, no book sources in the final image.

xtask build is used rather than xtask deploy because the two produce
identical content β€” deploy only differs in writing to docs/ and printing
GitHub Pages instructions, which are irrelevant in a container.

Pinned versions

MDBOOK_VERSION and MDBOOK_MERMAID_VERSION are build args in the Dockerfile.
CI (pages.yml) currently installs both unpinned via cargo install, so the
container may lag or lead the published site after an upstream mdbook release.
Bump the args when that matters.

Prebuilt release binaries are used where upstream publishes them, falling back
to cargo install otherwise. As of the pinned versions, mdbook-mermaid has no
published arm64 Linux binary, so arm64 builds compile it from source and take
noticeably longer.

Notes

  • The container runs as uid 101 and binds an unprivileged port, so it needs no
    root and no added capabilities.
  • Adding read_only: true to the service is possible but requires tmpfs mounts
    for nginx's cache and pid paths; it is left off by default rather than shipped
    untested.
  • Content is baked in at build time. Rebuild the image to pick up book changes.

--- METRICS ---