rust-docker

Master Docker containerization for Rust applications

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "rust-docker" with this command: npx skills add pluginagentmarketplace/custom-plugin-rust/pluginagentmarketplace-custom-plugin-rust-rust-docker

Rust Docker Skill

Master Docker containerization: multi-stage builds, minimal images, and production deployment.

Quick Start

Multi-Stage Dockerfile

# Build stage
FROM rust:1.75-alpine AS builder
RUN apk add --no-cache musl-dev
WORKDIR /app

# Cache dependencies
COPY Cargo.toml Cargo.lock ./
RUN mkdir src && echo "fn main() {}" > src/main.rs
RUN cargo build --release && rm -rf src

# Build app
COPY src ./src
RUN touch src/main.rs && cargo build --release

# Runtime (< 20MB)
FROM alpine:3.19
RUN apk add --no-cache ca-certificates
COPY --from=builder /app/target/release/my-app /usr/local/bin/

RUN adduser -D appuser
USER appuser

HEALTHCHECK CMD wget -qO- localhost:8080/health || exit 1
CMD ["my-app"]

Scratch Image (< 10MB)

FROM rust:1.75 AS builder
RUN rustup target add x86_64-unknown-linux-musl
RUN apt-get update && apt-get install -y musl-tools
WORKDIR /app
COPY . .
RUN cargo build --release --target x86_64-unknown-linux-musl

FROM scratch
COPY --from=builder /app/target/x86_64-unknown-linux-musl/release/my-app /
ENTRYPOINT ["/my-app"]

Docker Compose

version: '3.8'
services:
  app:
    build: .
    ports:
      - "8080:8080"
    environment:
      - RUST_LOG=info

Commands

docker build -t my-app .
docker run --rm -p 8080:8080 my-app
docker images my-app  # Check size

Troubleshooting

ProblemSolution
Slow buildsCache Cargo.toml
Large imagesUse multi-stage + alpine
SSL errorsAdd ca-certificates

Resources

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

Automation

error-handling

No summary provided by upstream source.

Repository SourceNeeds Review
Automation

rust-wasm

No summary provided by upstream source.

Repository SourceNeeds Review
Automation

rust-performance

No summary provided by upstream source.

Repository SourceNeeds Review